instantiate-expr-5.cpp 1.0 KB

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