summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-28 22:43:14 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-28 22:43:14 +0000
commitea679ec1256f339d577cd5ae2584bc009fb0f85a (patch)
treeb8442f61f46fd4db2d42057a39533721808938b6
parenta8a9d6a1f0a67641c7baca7eb3fc89786283601c (diff)
downloadbcm5719-llvm-ea679ec1256f339d577cd5ae2584bc009fb0f85a.tar.gz
bcm5719-llvm-ea679ec1256f339d577cd5ae2584bc009fb0f85a.zip
Fix template instantiation for __builtin_offfsetof expressions that refer to members of anonymous structs/unions
llvm-svn: 102551
-rw-r--r--clang/lib/Sema/TreeTransform.h3
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-5.cpp16
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 17f6553d0dc..4e32897df62 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4219,6 +4219,9 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
case Node::Identifier:
Comp.isBrackets = false;
Comp.U.IdentInfo = ON.getFieldName();
+ if (!Comp.U.IdentInfo)
+ continue;
+
break;
}
diff --git a/clang/test/SemaTemplate/instantiate-expr-5.cpp b/clang/test/SemaTemplate/instantiate-expr-5.cpp
index 916c4f94931..6cdedda4d88 100644
--- a/clang/test/SemaTemplate/instantiate-expr-5.cpp
+++ b/clang/test/SemaTemplate/instantiate-expr-5.cpp
@@ -19,4 +19,20 @@ namespace PR5880 {
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>();
}
OpenPOWER on IntegriCloud