]> granicus.if.org Git - clang/commitdiff
Fix template instantiation for __builtin_offfsetof expressions that refer to members...
authorDouglas Gregor <dgregor@apple.com>
Wed, 28 Apr 2010 22:43:14 +0000 (22:43 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 28 Apr 2010 22:43:14 +0000 (22:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102551 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-expr-5.cpp

index 17f6553d0dccfe3701c04b0a38a76e0f67b18e9b..4e32897df62f1ec70ee053b03c5cb980e60e710a 100644 (file)
@@ -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;
     }
     
index 916c4f949311cfb15858cd0d0db225ae25215ac0..6cdedda4d880a1bbc37e19bb0e6753740a61fb31 100644 (file)
@@ -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>();
 }