anonymous-union.cpp 837 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // PR5868
  3. struct T0 {
  4. int x;
  5. union {
  6. void *m0;
  7. };
  8. };
  9. template <typename T>
  10. struct T1 : public T0, public T { //expected-warning{{direct base 'T0' is inaccessible due to ambiguity:\n struct T1<struct A> -> struct T0\n struct T1<struct A> -> struct A -> struct T0}}
  11. void f0() {
  12. m0 = 0; // expected-error{{ambiguous conversion}}
  13. }
  14. };
  15. struct A : public T0 { };
  16. void f1(T1<A> *S) { S->f0(); } // expected-note{{instantiation of member function}} expected-note{{in instantiation of template class 'T1<A>' requested here}}
  17. namespace rdar8635664 {
  18. template<typename T>
  19. struct X {
  20. struct inner;
  21. struct inner {
  22. union {
  23. int x;
  24. float y;
  25. };
  26. typedef T type;
  27. };
  28. };
  29. void test() {
  30. X<int>::inner i;
  31. i.x = 0;
  32. }
  33. }