p2-places.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
  2. // Tests where specs are allowed and where they aren't.
  3. namespace dyn {
  4. // Straight from the standard:
  5. // Plain function with spec
  6. void f() throw(int);
  7. // Pointer to function with spec
  8. void (*fp)() throw (int);
  9. // Function taking reference to function with spec
  10. void g(void pfa() throw(int));
  11. // Typedef for pointer to function with spec
  12. typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}}
  13. // Some more:
  14. // Function returning function with spec
  15. void (*h())() throw(int);
  16. // Ultimate parser thrill: function with spec returning function with spec and
  17. // taking pointer to function with spec.
  18. // The actual function throws int, the return type double, the argument float.
  19. void (*i() throw(int))(void (*)() throw(float)) throw(double);
  20. // Pointer to pointer to function taking function with spec
  21. void (**k)(void pfa() throw(int)); // no-error
  22. // Pointer to pointer to function with spec
  23. void (**j)() throw(int); // expected-error {{not allowed beyond a single}}
  24. // Pointer to function returning pointer to pointer to function with spec
  25. void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}}
  26. }
  27. namespace noex {
  28. // These parallel those from above.
  29. void f() noexcept(false);
  30. void (*fp)() noexcept(false);
  31. void g(void pfa() noexcept(false));
  32. typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}}
  33. void (*h())() noexcept(false);
  34. void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false);
  35. void (**k)(void pfa() noexcept(false)); // no-error
  36. void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}}
  37. void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}}
  38. }