r175880 - Don't crash if we try to apply 'alignas' to a variable declared with an

Richard Smith richard-llvm at metafoo.co.uk
Fri Feb 22 01:21:42 PST 2013


Author: rsmith
Date: Fri Feb 22 03:21:42 2013
New Revision: 175880

URL: http://llvm.org/viewvc/llvm-project?rev=175880&view=rev
Log:
Don't crash if we try to apply 'alignas' to a variable declared with an
incomplete type.

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=175880&r1=175879&r2=175880&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Feb 22 03:21:42 2013
@@ -3441,7 +3441,7 @@ void Sema::CheckAlignasUnderalignment(De
     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:

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp?rev=175880&r1=175879&r2=175880&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp Fri Feb 22 03:21:42 2013
@@ -81,3 +81,6 @@ enum alignas(O) alignas(P) Y<M,N,O,P>::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}}





More information about the cfe-commits mailing list