Home | History | Annotate | Download | only in except.spec
      1 // RUN: %clang_cc1 -std=c++0x -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
      2 
      3 // Tests where specs are allowed and where they aren't.
      4 
      5 namespace dyn {
      6 
      7   // Straight from the standard:
      8 
      9   // Plain function with spec
     10   void f() throw(int);
     11 
     12   // Pointer to function with spec
     13   void (*fp)() throw (int);
     14 
     15   // Function taking reference to function with spec
     16   void g(void pfa() throw(int));
     17 
     18   // Typedef for pointer to function with spec
     19   typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}}
     20 
     21   // Some more:
     22 
     23   // Function returning function with spec
     24   void (*h())() throw(int);
     25 
     26   // Ultimate parser thrill: function with spec returning function with spec and
     27   // taking pointer to function with spec.
     28   // The actual function throws int, the return type double, the argument float.
     29   void (*i() throw(int))(void (*)() throw(float)) throw(double);
     30 
     31   // Pointer to pointer to function taking function with spec
     32   void (**k)(void pfa() throw(int)); // no-error
     33 
     34   // Pointer to pointer to function with spec
     35   void (**j)() throw(int); // expected-error {{not allowed beyond a single}}
     36 
     37   // Pointer to function returning pointer to pointer to function with spec
     38   void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}}
     39 
     40 }
     41 
     42 namespace noex {
     43 
     44   // These parallel those from above.
     45 
     46   void f() noexcept(false);
     47 
     48   void (*fp)() noexcept(false);
     49 
     50   void g(void pfa() noexcept(false));
     51 
     52   typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}}
     53 
     54   void (*h())() noexcept(false);
     55 
     56   void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false);
     57 
     58   void (**k)(void pfa() noexcept(false)); // no-error
     59 
     60   void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}}
     61 
     62   void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}}
     63 }
     64