]> granicus.if.org Git - clang/commitdiff
Don't add an imported function into its lexical context until *after*
authorDouglas Gregor <dgregor@apple.com>
Fri, 1 Oct 2010 23:55:07 +0000 (23:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 1 Oct 2010 23:55:07 +0000 (23:55 +0000)
we've set all of its parameters. Fixes <rdar://problem/8499598>;
thanks to Sean for the diagnosis.

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

lib/AST/ASTImporter.cpp
test/ASTMerge/Inputs/class1.cpp
test/ASTMerge/Inputs/class2.cpp

index 147a1ed4e76947dc102941660ae24964ba834e5b..78cb5365504366f12f9e96b4f9024e7fc1bd53cb 100644 (file)
@@ -1966,7 +1966,6 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   ToFunction->setAccess(D->getAccess());
   ToFunction->setLexicalDeclContext(LexicalDC);
   Importer.Imported(D, ToFunction);
-  LexicalDC->addDecl(ToFunction);
 
   // Set the parameters.
   for (unsigned I = 0, N = Parameters.size(); I != N; ++I) {
@@ -1976,7 +1975,10 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   ToFunction->setParams(Parameters.data(), Parameters.size());
 
   // FIXME: Other bits to merge?
-  
+
+  // Add this function to the lexical context.
+  LexicalDC->addDecl(ToFunction);
+
   return ToFunction;
 }
 
index e13faf0539b1b4eaae9187250d5a1b0a4dedc4d3..b600cdb1fcf913e029f99561231876078818df84 100644 (file)
@@ -6,3 +6,10 @@ struct B : A {
   float y;
   float foo();
 };
+
+struct C {
+  C(int i = 10);
+  C(const C&);
+  C &operator=(C&);
+  ~C();
+};
index 91b84dc13b7510f048ab17016d14be0d7b8a05c4..fa38916f5e2e48ce19de25c73e5abb530422f012 100644 (file)
@@ -6,3 +6,4 @@ struct B : A {
   int y;
   int foo();
 };
+