summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-02-03 15:47:04 +0000
committerHans Wennborg <hans@hanshq.net>2012-02-03 15:47:04 +0000
commitb64a1fa65ca177506322d7f55bd9681417d134eb (patch)
tree9250c62ed6e9de014e062e7cb6e12aef2710e078 /clang/lib/Sema/SemaDecl.cpp
parent5399f4d6bf42725e86427971307a3fc65cb03891 (diff)
downloadbcm5719-llvm-b64a1fa65ca177506322d7f55bd9681417d134eb.tar.gz
bcm5719-llvm-b64a1fa65ca177506322d7f55bd9681417d134eb.zip
Don't warn about anonymous struct/union in C11.
Also, in C, call this a C11 extension rather than a GNU extension. llvm-svn: 149695
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8a0e461ec2b..f6f97dddbca 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2679,18 +2679,20 @@ StorageClassSpecToFunctionDeclStorageClass(DeclSpec::SCS StorageClassSpec) {
/// BuildAnonymousStructOrUnion - Handle the declaration of an
/// anonymous structure or union. Anonymous unions are a C++ feature
-/// (C++ [class.union]) and a GNU C extension; anonymous structures
-/// are a GNU C and GNU C++ extension.
+/// (C++ [class.union]) and a C11 feature; anonymous structures
+/// are a C11 feature and GNU C++ extension.
Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
AccessSpecifier AS,
RecordDecl *Record) {
DeclContext *Owner = Record->getDeclContext();
// Diagnose whether this anonymous struct/union is an extension.
- if (Record->isUnion() && !getLangOptions().CPlusPlus)
+ if (Record->isUnion() && !getLangOptions().CPlusPlus && !getLangOptions().C11)
Diag(Record->getLocation(), diag::ext_anonymous_union);
- else if (!Record->isUnion())
- Diag(Record->getLocation(), diag::ext_anonymous_struct);
+ else if (!Record->isUnion() && getLangOptions().CPlusPlus)
+ Diag(Record->getLocation(), diag::ext_gnu_anonymous_struct);
+ else if (!Record->isUnion() && !getLangOptions().C11)
+ Diag(Record->getLocation(), diag::ext_c11_anonymous_struct);
// C and C++ require different kinds of checks for anonymous
// structs/unions.
OpenPOWER on IntegriCloud