aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-07 00:43:41 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-07 00:43:41 +0000
commitbcbffc46f1ad3796c4582fa1e3a9113b5aa26061 (patch)
treec87298e6e890898fc9a551c49fe7e7a50f384e70 /lib/AST
parent234a4c286e197f7ca9207d60433d40c802484333 (diff)
Initial implementation of anonymous unions (and, as a GNU extension,
structures and classes) in C++. Covers name lookup and the synthesis and member access for the unnamed objects/fields associated with anonymous unions. Some C++ semantic checks are still missing (anonymous unions can't have function members, static data members, etc.), and there is no support for anonymous structs or unions in C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61840 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/Decl.cpp3
-rw-r--r--lib/AST/DeclBase.cpp2
-rw-r--r--lib/AST/DeclSerialization.cpp2
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index bfe0272038..bfe8a184e8 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -290,7 +290,7 @@ OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
}
//===----------------------------------------------------------------------===//
-// TagdDecl Implementation
+// TagDecl Implementation
//===----------------------------------------------------------------------===//
TagDecl* TagDecl::getDefinition(ASTContext& C) const {
@@ -308,6 +308,7 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
: TagDecl(DK, TK, DC, L, Id, 0), DeclContext(DK) {
HasFlexibleArrayMember = false;
+ AnonymousStructOrUnion = false;
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
}
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index faaa1045de..cf612c2f3c 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -412,7 +412,7 @@ bool DeclContext::isTransparentContext() const {
else if (DeclKind == Decl::LinkageSpec)
return true;
else if (DeclKind == Decl::Record || DeclKind == Decl::CXXRecord)
- return false; // FIXME: need to know about anonymous unions/structs
+ return cast<RecordDecl>(this)->isAnonymousStructOrUnion();
else if (DeclKind == Decl::Namespace)
return false; // FIXME: Check for C++0x inline namespaces
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index 0a298139bd..38af462091 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -618,6 +618,7 @@ void RecordDecl::EmitImpl(Serializer& S) const {
ScopedDecl::EmitInRec(S);
S.EmitBool(isDefinition());
S.EmitBool(hasFlexibleArrayMember());
+ S.EmitBool(isAnonymousStructOrUnion());
ScopedDecl::EmitOutRec(S);
}
@@ -630,6 +631,7 @@ RecordDecl* RecordDecl::CreateImpl(Deserializer& D, ASTContext& C) {
decl->ScopedDecl::ReadInRec(D, C);
decl->setDefinition(D.ReadBool());
decl->setHasFlexibleArrayMember(D.ReadBool());
+ decl->setAnonymousStructOrUnion(D.ReadBool());
decl->ScopedDecl::ReadOutRec(D, C);
return decl;