[cfe-commits] r61037 - in /cfe/trunk/lib: AST/DeclBase.cpp Sema/SemaDeclCXX.cpp

Douglas Gregor dgregor at apple.com
Mon Dec 15 09:33:16 PST 2008


Author: dgregor
Date: Mon Dec 15 11:33:16 2008
New Revision: 61037

URL: http://llvm.org/viewvc/llvm-project?rev=61037&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=61037&r1=61036&r2=61037&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Dec 15 11:33:16 2008
@@ -321,7 +321,6 @@
 
 
 void Decl::Destroy(ASTContext& C) {
-
   if (ScopedDecl* SD = dyn_cast<ScopedDecl>(this)) {    
 
     // Observe the unrolled recursion.  By setting N->NextDeclarator = 0x0

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=61037&r1=61036&r2=61037&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec 15 11:33:16 2008
@@ -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;
 }





More information about the cfe-commits mailing list