aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-01 21:04:42 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-01 21:04:42 +0000
commit72f6d678c8de9f3a770e8ae5fc4979abf3940668 (patch)
tree8703932666cbdbe3fb8c5c09abc24ea8d3b3d010 /include/clang
parentcb3c308ef0e63b2902911b985517309c26f975dc (diff)
In CXXBaseOrMemberInitializer, don't confuse CtorTocall with
AnonUnionMember. Fixes PR4826. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/AST/DeclCXX.h49
1 files changed, 24 insertions, 25 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index a6d32476a7..4fcf51f107 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -819,28 +819,25 @@ class CXXBaseOrMemberInitializer {
Stmt **Args;
unsigned NumArgs;
- union {
- /// CtorToCall - For a base or member needing a constructor for their
- /// initialization, this is the constructor to call.
- CXXConstructorDecl *CtorToCall;
-
- /// AnonUnionMember - When 'BaseOrMember' is class's anonymous union
- /// data member, this field holds the FieldDecl for the member of the
- /// anonymous union being initialized.
- /// @code
- /// struct X {
- /// X() : au_i1(123) {}
- /// union {
- /// int au_i1;
- /// float au_f1;
- /// };
- /// };
- /// @endcode
- /// In above example, BaseOrMember holds the field decl. for anonymous union
- /// and AnonUnionMember holds field decl for au_i1.
- ///
- FieldDecl *AnonUnionMember;
- };
+ /// \brief Stores either the constructor to call to initialize this base or
+ /// member (a CXXConstructorDecl pointer), or stores the anonymous union of
+ /// which the initialized value is a member.
+ ///
+ /// When the value is a FieldDecl pointer, 'BaseOrMember' is class's
+ /// anonymous union data member, this field holds the FieldDecl for the
+ /// member of the anonymous union being initialized.
+ /// @code
+ /// struct X {
+ /// X() : au_i1(123) {}
+ /// union {
+ /// int au_i1;
+ /// float au_f1;
+ /// };
+ /// };
+ /// @endcode
+ /// In above example, BaseOrMember holds the field decl. for anonymous union
+ /// and AnonUnionMember holds field decl for au_i1.
+ llvm::PointerUnion<CXXConstructorDecl *, FieldDecl *> CtorOrAnonUnion;
/// IdLoc - Location of the id in ctor-initializer list.
SourceLocation IdLoc;
@@ -921,13 +918,15 @@ public:
}
FieldDecl *getAnonUnionMember() const {
- return AnonUnionMember;
+ return CtorOrAnonUnion.dyn_cast<FieldDecl *>();
}
void setAnonUnionMember(FieldDecl *anonMember) {
- AnonUnionMember = anonMember;
+ CtorOrAnonUnion = anonMember;
}
- const CXXConstructorDecl *getConstructor() const { return CtorToCall; }
+ const CXXConstructorDecl *getConstructor() const {
+ return CtorOrAnonUnion.dyn_cast<CXXConstructorDecl *>();
+ }
SourceLocation getSourceLocation() const { return IdLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }