From a0e6a7fcd89bf1924c0c082576bda26242258163 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 11 Jul 2013 22:22:22 +0000 Subject: [PATCH] Make CXXBaseSpecifier::getType return unqual type. Various pieces of code, like base initialization in Sema and RTTI IRGen, don't properly ignore qualifiers on base classes. Instead of auditing the whole codebase, just strip them off in the getter. (The type as written is still available in the TypeSourceInfo for code that cares.) Fixes PR16596. llvm-svn: 186125 --- clang/include/clang/AST/DeclCXX.h | 4 +++- clang/test/SemaCXX/class-base-member-init.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 155cbe5..52909fb 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -250,7 +250,9 @@ public: /// \brief Retrieves the type of the base class. /// /// This type will always be an unqualified class type. - QualType getType() const { return BaseTypeInfo->getType(); } + QualType getType() const { + return BaseTypeInfo->getType().getUnqualifiedType(); + } /// \brief Retrieves the type and source location of the base class. TypeSourceInfo *getTypeSourceInfo() const { return BaseTypeInfo; } diff --git a/clang/test/SemaCXX/class-base-member-init.cpp b/clang/test/SemaCXX/class-base-member-init.cpp index 2cdca82..8344e6f 100644 --- a/clang/test/SemaCXX/class-base-member-init.cpp +++ b/clang/test/SemaCXX/class-base-member-init.cpp @@ -98,3 +98,13 @@ namespace rdar13185264 { union { void *a; }; }; } + +namespace PR16596 { + class A { public: virtual ~A(); }; + typedef const A Foo; + void Apply(Foo processor); + struct Bar : public Foo {}; + void Fetch() { + Apply(Bar()); + } +} -- 2.7.4