Don't crash if we try to apply 'alignas' to a variable declared with an
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 22 Feb 2013 09:21:42 +0000 (09:21 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 22 Feb 2013 09:21:42 +0000 (09:21 +0000)
incomplete type.

llvm-svn: 175880

clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp

index 8e2bac6..5f6f81d 100644 (file)
@@ -3441,7 +3441,7 @@ void Sema::CheckAlignasUnderalignment(Decl *D) {
     Ty = VD->getType();
   else
     Ty = Context.getTagDeclType(cast<TagDecl>(D));
-  if (Ty->isDependentType())
+  if (Ty->isDependentType() || Ty->isIncompleteType())
     return;
 
   // C++11 [dcl.align]p5, C11 6.7.5/4:
index 8cf5b26..e788577 100644 (file)
@@ -81,3 +81,6 @@ enum alignas(O) alignas(P) Y<M,N,O,P>::E : char { e };
 int y1848 = Y<1,8,4,8>::e;
 // FIXME: We should reject this.
 int y1248 = Y<1,2,4,8>::e;
+
+// Don't crash here.
+alignas(4) struct Incomplete incomplete; // expected-error {{incomplete type}} expected-note {{forward declaration}}