Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Eli Friedman | de99a45 | 2009-07-22 22:25:00 +0000 | [diff] [blame] | 2 | |
| 3 | template <class A> int x(A x) { return x++; } |
| 4 | int y() { return x<int>(1); } |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 5 | |
| 6 | namespace PR5880 { |
| 7 | template<typename T> |
| 8 | struct A { |
| 9 | static const int a = __builtin_offsetof(T, a.array[5].m); // expected-error{{error: no member named 'a' in 'HasM'}} |
| 10 | }; |
| 11 | struct HasM { |
| 12 | float m; |
| 13 | }; |
| 14 | |
| 15 | struct ArrayOfHasM { |
| 16 | HasM array[10]; |
| 17 | }; |
| 18 | |
| 19 | struct B { ArrayOfHasM a; }; |
| 20 | A<B> x; |
| 21 | A<HasM> x2; // expected-note{{in instantiation of}} |
Douglas Gregor | 29d2fd5 | 2010-04-28 22:43:14 +0000 | [diff] [blame] | 22 | |
| 23 | template<typename T> |
| 24 | struct AnonymousUnion { |
| 25 | union { |
| 26 | int i; |
| 27 | float f; |
| 28 | }; |
| 29 | }; |
| 30 | |
| 31 | template<typename T> |
| 32 | void test_anon_union() { |
| 33 | int array1[__builtin_offsetof(AnonymousUnion<T>, f) == 0? 1 : -1]; |
| 34 | int array2[__builtin_offsetof(AnonymousUnion<int>, f) == 0? 1 : -1]; |
| 35 | } |
| 36 | |
| 37 | template void test_anon_union<int>(); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 38 | } |