aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-02-22 09:21:42 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-02-22 09:21:42 +0000
commit4da090394caafe7be5b66ad03409c06566444926 (patch)
tree2347f0abd27f8fe105a0fea8c0dcd530c70c5abf
parent672edb0a04a5273e3a501f3b196844c125290780 (diff)
Don't crash if we try to apply 'alignas' to a variable declared with an
incomplete type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175880 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclAttr.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 8e2bac6ed0..5f6f81de14 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -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:
diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp
index 8cf5b266bb..e788577480 100644
--- a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp
+++ b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp
@@ -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}}