p7-0x.cpp 885 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
  2. struct X1 {
  3. X1();
  4. };
  5. struct X2 {
  6. X2();
  7. ~X2();
  8. };
  9. struct X3 {
  10. X3(const X3&) = default;
  11. };
  12. struct X4 {
  13. X4(const X4&) = default;
  14. X4(X4&);
  15. };
  16. void vararg(...);
  17. void g();
  18. void f(X1 x1, X2 x2, X3 x3, X4 x4) {
  19. vararg(x1); // OK
  20. vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
  21. vararg(x3); // OK
  22. vararg(x4); // expected-error{{cannot pass object of non-trivial type 'X4' through variadic function; call will abort at runtime}}
  23. vararg(g()); // expected-error{{cannot pass expression of type 'void' to variadic function}}
  24. vararg({1, 2, 3}); // expected-error{{cannot pass initializer list to variadic function}}
  25. }
  26. namespace PR11131 {
  27. struct S;
  28. S &getS();
  29. int f(...);
  30. void g() {
  31. (void)sizeof(f(getS()));
  32. }
  33. }