summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/ASTImporter.cpp13
-rw-r--r--clang/test/ASTMerge/Inputs/inheritance-base.cpp7
-rw-r--r--clang/test/ASTMerge/inheritance.cpp8
3 files changed, 26 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 3598dccf0a1..c1dda3fcf65 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -2820,8 +2820,17 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
Decl *CDecl = Importer.Import(DCXX->getLambdaContextDecl());
if (DCXX->getLambdaContextDecl() && !CDecl)
return nullptr;
- D2CXX->setLambdaMangling(DCXX->getLambdaManglingNumber(),
- CDecl);
+ D2CXX->setLambdaMangling(DCXX->getLambdaManglingNumber(), CDecl);
+ } else if (DCXX->isInjectedClassName()) {
+ // We have to be careful to do a similar dance to the one in
+ // Sema::ActOnStartCXXMemberDeclarations
+ CXXRecordDecl *const PrevDecl = nullptr;
+ const bool DelayTypeCreation = true;
+ D2CXX = CXXRecordDecl::Create(
+ Importer.getToContext(), D->getTagKind(), DC, StartLoc, Loc,
+ Name.getAsIdentifierInfo(), PrevDecl, DelayTypeCreation);
+ Importer.getToContext().getTypeDeclType(
+ D2CXX, llvm::dyn_cast<CXXRecordDecl>(DC));
} else {
D2CXX = CXXRecordDecl::Create(Importer.getToContext(),
D->getTagKind(),
diff --git a/clang/test/ASTMerge/Inputs/inheritance-base.cpp b/clang/test/ASTMerge/Inputs/inheritance-base.cpp
new file mode 100644
index 00000000000..26fe42eb64d
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/inheritance-base.cpp
@@ -0,0 +1,7 @@
+class A
+{
+public:
+ int x;
+ A(int _x) : x(_x) {
+ }
+};
diff --git a/clang/test/ASTMerge/inheritance.cpp b/clang/test/ASTMerge/inheritance.cpp
new file mode 100644
index 00000000000..7fce82a736a
--- /dev/null
+++ b/clang/test/ASTMerge/inheritance.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/inheritance-base.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class B : public A {
+ B(int _a) : A(_a) {
+ }
+};
OpenPOWER on IntegriCloud