aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2011-07-11 08:52:40 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2011-07-11 08:52:40 +0000
commitcdb8076dd9cfb975a1bcb3e7cb58a59648c35af0 (patch)
tree34be0667eb614088176f4e6ade97ed27b1d095a2
parent386b0075d02837cba066d299adb0bbc6c3ebd2ee (diff)
Fixed PR10243.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134892 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp22
-rw-r--r--test/SemaCXX/PR10243.cpp23
2 files changed, 39 insertions, 6 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index f4fd20ef7b..e20ec40b6a 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -3387,7 +3387,7 @@ void Sema::CheckExplicitlyDefaultedDestructor(CXXDestructorDecl *DD) {
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::ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD) {
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::ShouldDeleteCopyConstructor(CXXConstructorDecl *CD) {
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::ShouldDeleteCopyAssignmentOperator(CXXMethodDecl *MD) {
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 @@ Sema::ComputeDefaultedDefaultCtorExceptionSpec(CXXRecordDecl *ClassDecl) {
// 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 @@ Sema::ComputeDefaultedDtorExceptionSpec(CXXRecordDecl *ClassDecl) {
// 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 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
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 @@ Sema::ComputeDefaultedCopyAssignmentExceptionSpecAndConst(
if (CXXMethodDecl *CopyAssign =
LookupCopyingAssignment(FieldClassDecl, ArgQuals, false, 0))
ExceptSpec.CalledDecl(CopyAssign);
- }
+ }
}
return std::make_pair(ExceptSpec, HasConstCopyAssignment);
@@ -7063,6 +7070,9 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
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
diff --git a/test/SemaCXX/PR10243.cpp b/test/SemaCXX/PR10243.cpp
new file mode 100644
index 0000000000..9a58510498
--- /dev/null
+++ b/test/SemaCXX/PR10243.cpp
@@ -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;
+};