[cfe-commits] r102551 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-expr-5.cpp
Douglas Gregor
dgregor at apple.com
Wed Apr 28 15:43:14 PDT 2010
Author: dgregor
Date: Wed Apr 28 17:43:14 2010
New Revision: 102551
URL: http://llvm.org/viewvc/llvm-project?rev=102551&view=rev
Log:
Fix template instantiation for __builtin_offfsetof expressions that refer to members of anonymous structs/unions
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/instantiate-expr-5.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=102551&r1=102550&r2=102551&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Apr 28 17:43:14 2010
@@ -4219,6 +4219,9 @@
case Node::Identifier:
Comp.isBrackets = false;
Comp.U.IdentInfo = ON.getFieldName();
+ if (!Comp.U.IdentInfo)
+ continue;
+
break;
}
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-5.cpp?rev=102551&r1=102550&r2=102551&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-5.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-5.cpp Wed Apr 28 17:43:14 2010
@@ -19,4 +19,20 @@
struct B { ArrayOfHasM a; };
A<B> x;
A<HasM> x2; // expected-note{{in instantiation of}}
+
+ template<typename T>
+ struct AnonymousUnion {
+ union {
+ int i;
+ float f;
+ };
+ };
+
+ template<typename T>
+ void test_anon_union() {
+ int array1[__builtin_offsetof(AnonymousUnion<T>, f) == 0? 1 : -1];
+ int array2[__builtin_offsetof(AnonymousUnion<int>, f) == 0? 1 : -1];
+ }
+
+ template void test_anon_union<int>();
}
More information about the cfe-commits
mailing list