[cfe-commits] r134892 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/PR10243.cpp

Abramo Bagnara abramo.bagnara at gmail.com
Mon Jul 11 01:52:40 PDT 2011


Author: abramo
Date: Mon Jul 11 03:52:40 2011
New Revision: 134892

URL: http://llvm.org/viewvc/llvm-project?rev=134892&view=rev
Log:
Fixed PR10243.

Added:
    cfe/trunk/test/SemaCXX/PR10243.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=134892&r1=134891&r2=134892&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jul 11 03:52:40 2011
@@ -3387,7 +3387,7 @@
 bool Sema::ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD) {
   CXXRecordDecl *RD = CD->getParent();
   assert(!RD->isDependentType() && "do deletion after instantiation");
-  if (!LangOpts.CPlusPlus0x)
+  if (!LangOpts.CPlusPlus0x || RD->isInvalidDecl())
     return false;
 
   SourceLocation Loc = CD->getLocation();
@@ -3568,7 +3568,7 @@
 bool Sema::ShouldDeleteCopyConstructor(CXXConstructorDecl *CD) {
   CXXRecordDecl *RD = CD->getParent();
   assert(!RD->isDependentType() && "do deletion after instantiation");
-  if (!LangOpts.CPlusPlus0x)
+  if (!LangOpts.CPlusPlus0x || RD->isInvalidDecl())
     return false;
 
   SourceLocation Loc = CD->getLocation();
@@ -3724,7 +3724,7 @@
 bool Sema::ShouldDeleteCopyAssignmentOperator(CXXMethodDecl *MD) {
   CXXRecordDecl *RD = MD->getParent();
   assert(!RD->isDependentType() && "do deletion after instantiation");
-  if (!LangOpts.CPlusPlus0x)
+  if (!LangOpts.CPlusPlus0x || RD->isInvalidDecl())
     return false;
 
   SourceLocation Loc = MD->getLocation();
@@ -3849,7 +3849,7 @@
 bool Sema::ShouldDeleteDestructor(CXXDestructorDecl *DD) {
   CXXRecordDecl *RD = DD->getParent();
   assert(!RD->isDependentType() && "do deletion after instantiation");
-  if (!LangOpts.CPlusPlus0x)
+  if (!LangOpts.CPlusPlus0x || RD->isInvalidDecl())
     return false;
 
   SourceLocation Loc = DD->getLocation();
@@ -5881,6 +5881,8 @@
   //   An implicitly declared special member function (Clause 12) shall have an 
   //   exception-specification. [...]
   ImplicitExceptionSpecification ExceptSpec(Context);
+  if (ClassDecl->isInvalidDecl())
+    return ExceptSpec;
 
   // Direct base-class constructors.
   for (CXXRecordDecl::base_class_iterator B = ClassDecl->bases_begin(),
@@ -6254,7 +6256,9 @@
   //   An implicitly declared special member function (Clause 12) shall have 
   //   an exception-specification.
   ImplicitExceptionSpecification ExceptSpec(Context);
-  
+  if (ClassDecl->isInvalidDecl())
+    return ExceptSpec;
+
   // Direct base-class destructors.
   for (CXXRecordDecl::base_class_iterator B = ClassDecl->bases_begin(),
                                        BEnd = ClassDecl->bases_end();
@@ -6589,6 +6593,9 @@
 std::pair<Sema::ImplicitExceptionSpecification, bool>
 Sema::ComputeDefaultedCopyAssignmentExceptionSpecAndConst(
                                                    CXXRecordDecl *ClassDecl) {
+  if (ClassDecl->isInvalidDecl())
+    return std::make_pair(ImplicitExceptionSpecification(Context), false);
+
   // C++ [class.copy]p10:
   //   If the class definition does not explicitly declare a copy
   //   assignment operator, one is declared implicitly.
@@ -6694,7 +6701,7 @@
       if (CXXMethodDecl *CopyAssign =
           LookupCopyingAssignment(FieldClassDecl, ArgQuals, false, 0))
         ExceptSpec.CalledDecl(CopyAssign);
-    }      
+    }
   }
 
   return std::make_pair(ExceptSpec, HasConstCopyAssignment);
@@ -7063,6 +7070,9 @@
 
 std::pair<Sema::ImplicitExceptionSpecification, bool>
 Sema::ComputeDefaultedCopyCtorExceptionSpecAndConst(CXXRecordDecl *ClassDecl) {
+  if (ClassDecl->isInvalidDecl())
+    return std::make_pair(ImplicitExceptionSpecification(Context), false);
+
   // C++ [class.copy]p5:
   //   The implicitly-declared copy constructor for a class X will
   //   have the form

Added: cfe/trunk/test/SemaCXX/PR10243.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR10243.cpp?rev=134892&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/PR10243.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR10243.cpp Mon Jul 11 03:52:40 2011
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+struct S; // expected-note 4{{forward declaration of 'S'}}
+
+struct T0 {
+  S s; // expected-error{{field has incomplete type 'S'}}
+  T0() = default;
+};
+
+struct T1 {
+  S s; // expected-error{{field has incomplete type 'S'}}
+  T1(T1&) = default;
+};
+
+struct T2 {
+  S s; // expected-error{{field has incomplete type 'S'}}
+  T2& operator=(T2&) = default;
+};
+
+struct T3 {
+  S s; // expected-error{{field has incomplete type 'S'}}
+  ~T3() = default;
+};





More information about the cfe-commits mailing list