summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-06 23:06:59 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-06 23:06:59 +0000
commit2e7cba62082a40061fd34343f6c31c56bb006ff5 (patch)
tree8f0736a5a22426c03e41fabdc138062eec733d9a /clang/lib/Sema/SemaDecl.cpp
parentf5d0613ce9afa2db0b34d9b5805ebeef6ec81162 (diff)
downloadbcm5719-llvm-2e7cba62082a40061fd34343f6c31c56bb006ff5.tar.gz
bcm5719-llvm-2e7cba62082a40061fd34343f6c31c56bb006ff5.zip
Use the 'declaration does not declare anything' error when we see an anonymous struct/union declaration outside of a struct or union in C
llvm-svn: 66303
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 50113ee4b7f..5e7ce52ee87 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -922,8 +922,14 @@ Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
if (RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
if (!Record->getDeclName() && Record->isDefinition() &&
- DS.getStorageClassSpec() != DeclSpec::SCS_typedef)
- return BuildAnonymousStructOrUnion(S, DS, Record);
+ DS.getStorageClassSpec() != DeclSpec::SCS_typedef) {
+ if (getLangOptions().CPlusPlus ||
+ Record->getDeclContext()->isRecord())
+ return BuildAnonymousStructOrUnion(S, DS, Record);
+
+ Diag(DS.getSourceRange().getBegin(), diag::err_no_declarators)
+ << DS.getSourceRange();
+ }
// Microsoft allows unnamed struct/union fields. Don't complain
// about them.
@@ -1102,14 +1108,7 @@ Sema::DeclTy *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
Invalid = true;
}
}
- } else {
- // FIXME: Check GNU C semantics
- if (Record->isUnion() && !Owner->isRecord()) {
- Diag(Record->getLocation(), diag::err_anonymous_union_not_member)
- << (int)getLangOptions().CPlusPlus;
- Invalid = true;
- }
- }
+ }
if (!Record->isUnion() && !Owner->isRecord()) {
Diag(Record->getLocation(), diag::err_anonymous_struct_not_member)
OpenPOWER on IntegriCloud