diff options
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/cxx11-crashes.cpp | 38 |
2 files changed, 39 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index c898d81a61..12452b2429 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -8154,7 +8154,7 @@ hasMoveOrIsTriviallyCopyable(Sema &S, QualType Type, bool IsConstructor) { // reference types, are supposed to return false here, but that appears // to be a standard defect. CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl(); - if (!ClassDecl || !ClassDecl->getDefinition()) + if (!ClassDecl || !ClassDecl->getDefinition() || ClassDecl->isInvalidDecl()) return true; if (Type.isTriviallyCopyableType(S.Context)) diff --git a/test/SemaCXX/cxx11-crashes.cpp b/test/SemaCXX/cxx11-crashes.cpp new file mode 100644 index 0000000000..d5db10962f --- /dev/null +++ b/test/SemaCXX/cxx11-crashes.cpp @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// rdar://12240916 stack overflow. +namespace rdar12240916 { + +struct S2 { + S2(const S2&); + S2(); +}; + +struct S { // expected-note {{not complete}} + S x; // expected-error {{incomplete type}} + S2 y; +}; + +S foo() { + S s; + return s; +} + +struct S3; // expected-note {{forward declaration}} + +struct S4 { + S3 x; // expected-error {{incomplete type}} + S2 y; +}; + +struct S3 { + S4 x; + S2 y; +}; + +S4 foo2() { + S4 s; + return s; +} + +} |