[cfe-commits] r80659 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-anonymous-union.cpp
Anders Carlsson
andersca at mac.com
Mon Aug 31 21:31:03 PDT 2009
Author: andersca
Date: Mon Aug 31 23:31:02 2009
New Revision: 80659
URL: http://llvm.org/viewvc/llvm-project?rev=80659&view=rev
Log:
Handle member initializers that point to fields in anonymous structs.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/instantiate-anonymous-union.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=80659&r1=80658&r2=80659&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Aug 31 23:31:02 2009
@@ -1153,8 +1153,13 @@
Init->getRParenLoc(),
New->getParent());
} else if (Init->isMemberInitializer()) {
- FieldDecl *Member =
- cast<FieldDecl>(FindInstantiatedDecl(Init->getMember()));
+ FieldDecl *Member;
+
+ // Is this an anonymous union?
+ if (FieldDecl *UnionInit = Init->getAnonUnionMember())
+ Member = cast<FieldDecl>(UnionInit);
+ else
+ Member = cast<FieldDecl>(FindInstantiatedDecl(Init->getMember()));
NewInit = BuildMemberInitializer(Member, (Expr **)NewArgs.data(),
NewArgs.size(),
Modified: cfe/trunk/test/SemaTemplate/instantiate-anonymous-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-anonymous-union.cpp?rev=80659&r1=80658&r2=80659&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-anonymous-union.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-anonymous-union.cpp Mon Aug 31 23:31:02 2009
@@ -19,3 +19,15 @@
};
B<int> b0;
+
+template <typename T> struct C {
+ union {
+ int a;
+ void* b;
+ };
+
+ C(int a) : a(a) { }
+ C(void* b) : b(b) { }
+};
+
+C<int> c0;
More information about the cfe-commits
mailing list