cxx11-exception-spec.cpp 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t.1
  2. // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.1 -emit-pch %s -o %t.2
  3. // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -verify %s
  4. // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t.2 -emit-llvm-only %s
  5. // expected-no-diagnostics
  6. #ifndef PHASE1_DONE
  7. #define PHASE1_DONE
  8. template<int n> int f() noexcept(n % 2) { return 0; }
  9. template<int n> int g() noexcept(n % 2);
  10. decltype(f<2>()) f0;
  11. decltype(f<3>()) f1;
  12. template int f<4>();
  13. template int f<5>();
  14. decltype(f<6>()) f6;
  15. decltype(f<7>()) f7;
  16. struct A {
  17. A();
  18. A(const A&);
  19. };
  20. decltype(g<0>()) g0;
  21. #elif !defined(PHASE2_DONE)
  22. #define PHASE2_DONE
  23. template int f<6>();
  24. template int f<7>();
  25. decltype(f<8>()) f8;
  26. decltype(f<9>()) f9;
  27. template int f<10>();
  28. template int f<11>();
  29. A::A() = default;
  30. A::A(const A&) = default;
  31. int g0val = g<0>();
  32. #else
  33. static_assert(!noexcept(f<0>()), "");
  34. static_assert(noexcept(f<1>()), "");
  35. #endif