summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2010-11-21 06:08:52 +0000
committerFrancois Pichet <pichet2000@gmail.com>2010-11-21 06:08:52 +0000
commit783dd6ece4d1cacbbe9c5790c5a0b6cf9a4b7c9c (patch)
tree835aace2ba6a248986b02e383139a1f63bfb80fa /clang/lib/Sema/SemaDeclCXX.cpp
parente040a46eb354d1eb3d2102b416620e869a10883b (diff)
downloadbcm5719-llvm-783dd6ece4d1cacbbe9c5790c5a0b6cf9a4b7c9c.tar.gz
bcm5719-llvm-783dd6ece4d1cacbbe9c5790c5a0b6cf9a4b7c9c.zip
Major anonymous union/struct redesign.
A new AST node is introduced: def IndirectField : DDecl<Value>; IndirectFields are injected into the anonymous's parent scope and chain back to the original field. Name lookup for anonymous entities now result in an IndirectFieldDecl instead of a FieldDecl. There is no functionality change, the code generated should be the same. llvm-svn: 119919
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 2741c6de657..235b41e342e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1067,10 +1067,15 @@ Sema::ActOnMemInitializer(Decl *ConstructorD,
FieldDecl *Member = 0;
DeclContext::lookup_result Result
= ClassDecl->lookup(MemberOrBase);
- if (Result.first != Result.second)
+ if (Result.first != Result.second) {
Member = dyn_cast<FieldDecl>(*Result.first);
-
- // FIXME: Handle members of an anonymous union.
+
+ // Handle anonymous union case.
+ if (!Member)
+ if (IndirectFieldDecl* IndirectField
+ = dyn_cast<IndirectFieldDecl>(*Result.first))
+ Member = IndirectField->getAnonField();
+ }
if (Member)
return BuildMemberInitializer(Member, (Expr**)Args, NumArgs, IdLoc,
@@ -2600,15 +2605,15 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) {
// In addition, if class T has a user-declared constructor (12.1), every
// non-static data member of class T shall have a name different from T.
for (DeclContext::lookup_result R = Record->lookup(Record->getDeclName());
- R.first != R.second; ++R.first)
- if (FieldDecl *Field = dyn_cast<FieldDecl>(*R.first)) {
- if (Record->hasUserDeclaredConstructor() ||
- !Field->getDeclContext()->Equals(Record)) {
- Diag(Field->getLocation(), diag::err_member_name_of_class)
- << Field->getDeclName();
+ R.first != R.second; ++R.first) {
+ NamedDecl *D = *R.first;
+ if ((isa<FieldDecl>(D) && Record->hasUserDeclaredConstructor()) ||
+ isa<IndirectFieldDecl>(D)) {
+ Diag(D->getLocation(), diag::err_member_name_of_class)
+ << D->getDeclName();
break;
}
- }
+ }
}
}
OpenPOWER on IntegriCloud