From: Eli Friedman Date: Thu, 11 Jul 2013 22:22:22 +0000 (+0000) Subject: Make CXXBaseSpecifier::getType return unqual type. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf2901abf346c64792e3beb1e7dfeecff0b313f7;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186125 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 155cbe5032..52909fbb03 100644 --- a/include/clang/AST/DeclCXX.h +++ b/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/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp index 2cdca829ff..8344e6f49a 100644 --- a/test/SemaCXX/class-base-member-init.cpp +++ b/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()); + } +}