]> granicus.if.org Git - clang/commitdiff
[modules] For an inheriting constructor, the inherited constructor is stored in
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 27 Feb 2015 01:57:00 +0000 (01:57 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 27 Feb 2015 01:57:00 +0000 (01:57 +0000)
a map keyed off the canonical declaration. Don't try to set it if we're loading
some non-canonical merged declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230716 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/cxx-decls-imported.h
test/Modules/Inputs/cxx-decls-merged.h
test/Modules/cxx-decls.cpp

index a10ae1edf94237b4d9f8de391b805ee1205fdba0..97e43b700b924ad9589cc484bf2d9a65455ce91b 100644 (file)
@@ -1611,7 +1611,8 @@ void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
   VisitCXXMethodDecl(D);
 
   if (auto *CD = ReadDeclAs<CXXConstructorDecl>(Record, Idx))
-    D->setInheritedConstructor(CD);
+    if (D->isCanonicalDecl())
+      D->setInheritedConstructor(CD);
   D->IsExplicitSpecified = Record[Idx++];
   // FIXME: We should defer loading this until we need the constructor's body.
   std::tie(D->CtorInitializers, D->NumCtorInitializers) =
index 8c1e74f17c3cc962c155237f5bd7d914677b4e3c..a4910fee753e792b583de082439fdb3e5c14c9d5 100644 (file)
@@ -47,3 +47,6 @@ typedef decltype(name_for_linkage2_inner_a) NameForLinkage2Inner;
 
 namespace Aliased { extern int a; }
 namespace Alias = Aliased;
+
+struct InhCtorA { InhCtorA(int); };
+struct InhCtorB : InhCtorA { using InhCtorA::InhCtorA; };
index 86e81a9bb681f19b21d30cc45551045a16735688..5eefb44992f2ac88ccc0a3b7660588d85febde8c 100644 (file)
@@ -25,3 +25,6 @@ typedef decltype(name_for_linkage2_inner_b) NameForLinkage2Inner;
 
 namespace Aliased { extern int b; }
 namespace Alias = Aliased;
+
+struct InhCtorA { InhCtorA(int); };
+struct InhCtorB : InhCtorA { using InhCtorA::InhCtorA; };
index 109306ed79dfd33d2819aae3fa5ed4069f517108..4064040c12574d4228bc80d5cbeaca00b98958f4 100644 (file)
@@ -52,5 +52,7 @@ int use_namespace_alias() { return Alias::a + Alias::b; }
 
 void use_extern_c_function_2() { ExternCFunction(); }
 
+InhCtorB inhctorb(2);
+
 // CHECK: VarDecl [[mergeUsedFlag:0x[0-9a-f]*]] {{.*}} in cxx_decls.imported used mergeUsedFlag
 // CHECK: VarDecl {{0x[0-9a-f]*}} prev [[mergeUsedFlag]] {{.*}} in cxx_decls_merged used mergeUsedFlag