[cfe-commits] r165623 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/cxx11-crashes.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Oct 10 09:14:06 PDT 2012
Author: akirtzidis
Date: Wed Oct 10 11:14:06 2012
New Revision: 165623
URL: http://llvm.org/viewvc/llvm-project?rev=165623&view=rev
Log:
Fix stack overflow when trying to create an implicit moving
constructor with invalid code.
rdar://12240916
Added:
cfe/trunk/test/SemaCXX/cxx11-crashes.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=165623&r1=165622&r2=165623&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Oct 10 11:14:06 2012
@@ -8154,7 +8154,7 @@
// 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))
Added: cfe/trunk/test/SemaCXX/cxx11-crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-crashes.cpp?rev=165623&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-crashes.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx11-crashes.cpp Wed Oct 10 11:14:06 2012
@@ -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;
+}
+
+}
More information about the cfe-commits
mailing list