summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2010-09-15 00:14:08 +0000
committerFrancois Pichet <pichet2000@gmail.com>2010-09-15 00:14:08 +0000
commitf657b639fda1940534a305ddd7d26bf323666a14 (patch)
tree2cb3879b9d31066c9bacac9c8c4463ce0ba40314 /clang/lib/Sema
parent89bf5e9105806b9c9821ba950be60ee3faf12f9d (diff)
downloadbcm5719-llvm-f657b639fda1940534a305ddd7d26bf323666a14.tar.gz
bcm5719-llvm-f657b639fda1940534a305ddd7d26bf323666a14.zip
Microsoft's flexible array rules relaxation:
- in union - as the only element of a struct/class. llvm-svn: 113909
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 21b328d64ce..e314c1acfe4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6619,10 +6619,22 @@ void Sema::ActOnFields(Scope* S,
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
- } else if (FDTy->isIncompleteArrayType() && i == NumFields - 1 &&
- Record && !Record->isUnion()) {
+ } else if (FDTy->isIncompleteArrayType() && Record &&
+ ((i == NumFields - 1 && !Record->isUnion()) ||
+ (getLangOptions().Microsoft &&
+ (i == NumFields - 1 || Record->isUnion())))) {
// Flexible array member.
- if (NumNamedMembers < 1) {
+ // Microsoft is more permissive regarding flexible array.
+ // It will accept flexible array in union and also
+ // as the sole element of a struct/class.
+ if (getLangOptions().Microsoft) {
+ if (Record->isUnion())
+ Diag(FD->getLocation(), diag::ext_flexible_array_union)
+ << FD->getDeclName();
+ else if (NumFields == 1)
+ Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate)
+ << FD->getDeclName() << Record->getTagKind();
+ } else if (NumNamedMembers < 1) {
Diag(FD->getLocation(), diag::err_flexible_array_empty_struct)
<< FD->getDeclName();
FD->setInvalidDecl();
@@ -6637,7 +6649,6 @@ void Sema::ActOnFields(Scope* S,
EnclosingDecl->setInvalidDecl();
continue;
}
-
// Okay, we have a legal flexible array member at the end of the struct.
if (Record)
Record->setHasFlexibleArrayMember(true);
OpenPOWER on IntegriCloud