p5-0x.cpp 715 B

1234567891011121314151617181920212223242526
  1. // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
  2. // [class.base.init]p5
  3. // A ctor-initializer may initialize a variant member of the constructor’s
  4. // class. If a ctor-initializer specifies more than one mem-initializer for the
  5. // same member or for the same base class, the ctor-initializer is ill-formed.
  6. union E {
  7. int a;
  8. int b;
  9. E() : a(1), // expected-note{{previous initialization is here}}
  10. b(2) { // expected-error{{initializing multiple members of union}}
  11. }
  12. };
  13. union F {
  14. struct {
  15. int a;
  16. int b;
  17. };
  18. int c;
  19. F() : a(1), // expected-note{{previous initialization is here}}
  20. b(2),
  21. c(3) { // expected-error{{initializing multiple members of union}}
  22. }
  23. };