Don't double-destroy constructors defined out-of-line. This is a
half-solution; the real solution is coming when constructors and
destructors are treated like all other functions by ActOnDeclarator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61037 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index c3e947d..1efb174 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1112,13 +1112,17 @@
   // Make sure this constructor is an overload of the existing
   // constructors.
   OverloadedFunctionDecl::function_iterator MatchedDecl;
-  if (!IsOverload(ConDecl, ClassDecl->getConstructors(), MatchedDecl) &&
-      CurContext == (*MatchedDecl)->getLexicalDeclContext()) {
-    Diag(ConDecl->getLocation(), diag::err_constructor_redeclared)
-      << SourceRange(ConDecl->getLocation());
-    Diag((*MatchedDecl)->getLocation(), diag::note_previous_declaration)
-      << SourceRange((*MatchedDecl)->getLocation());
-    ConDecl->setInvalidDecl();
+  if (!IsOverload(ConDecl, ClassDecl->getConstructors(), MatchedDecl)) {
+    if (CurContext == (*MatchedDecl)->getLexicalDeclContext()) {
+      Diag(ConDecl->getLocation(), diag::err_constructor_redeclared)
+        << SourceRange(ConDecl->getLocation());
+      Diag((*MatchedDecl)->getLocation(), diag::note_previous_declaration)
+        << SourceRange((*MatchedDecl)->getLocation());
+      ConDecl->setInvalidDecl();
+      return 0;
+    }
+
+    // FIXME: Just drop the definition (for now).
     return ConDecl;
   }
 
@@ -1142,7 +1146,7 @@
   }
       
   // Add this constructor to the set of constructors of the current
-  // class.
+  // class. 
   ClassDecl->addConstructor(Context, ConDecl);
   return (DeclTy *)ConDecl;
 }