// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
// Exception specification compatibility.
// We test function pointers, because functions have an extra rule in p4.
// Same type is compatible
extern void throw;
extern void throw;
// Typedefs don't matter.
typedef int INT;
extern void throw;
extern void throw;
// Order doesn't matter.
extern void throw;
extern void throw;
// MS throw-any spec and no spec at all are compatible
extern void ;
extern void throw;
// throw(X) and no spec are not compatible
extern void throw; // expected-note {{previous declaration}}
extern void ; // expected-error {{exception specification in declaration does not match}}
// throw(int) and no spec are not compatible
extern void throw; // expected-note {{previous declaration}}
extern void ; // expected-error {{missing exception specification}}
// Different types are not compatible.
extern void throw; // expected-note {{previous declaration}}
extern void throw; // expected-error {{exception specification in declaration does not match}}
// Top-level const doesn't matter.
extern void throw;
extern void throw;
// Multiple appearances don't matter.
extern void throw;
extern void throw;
// noexcept is compatible with itself
extern void noexcept;
extern void noexcept;
// noexcept(true) is compatible with noexcept
extern void noexcept;
extern void noexcept;
// noexcept(false) isn't
extern void noexcept; // expected-note {{previous declaration}}
extern void noexcept; // expected-error {{does not match}}
// The form of the boolean expression doesn't matter.
extern void noexcept;
extern void noexcept;
// noexcept(false) is incompatible with noexcept(true)
extern void noexcept; // expected-note {{previous declaration}}
extern void noexcept; // expected-error {{does not match}}
// noexcept(false) is compatible with itself
extern void noexcept;
extern void noexcept;
// noexcept(false) is compatible with MS throw(...)
extern void noexcept;
extern void throw;
// noexcept(false) is *not* compatible with no spec
extern void ; // expected-note {{previous declaration}}
extern void noexcept; // expected-error {{does not match}}
// except for functions
void ;
void ;
// noexcept(false) is compatible with dynamic specs that throw unless
// CWG 1073 resolution is accepted. Clang implements it.
//extern void (*r18)() throw(int);
//extern void (*r18)() noexcept(false);
// noexcept(true) is compatible with dynamic specs that don't throw
extern void throw;
extern void noexcept;
// The other way round doesn't work.
extern void throw; // expected-note {{previous declaration}}
extern void noexcept; // expected-error {{does not match}}
extern void throw; // expected-note {{previous declaration}}
extern void noexcept; // expected-error {{does not match}}
// As a very special workaround, we allow operator new to match no spec
// with a throw(bad_alloc) spec, because C++0x makes an incompatible change
// here.
extern "C++"
typedef decltype mysize_t;
void* operator new throw;
void* operator new;
void* operator new;
void* operator new throw;
void ;
void ;
void ; // expected-note {{previous}}
void ; // expected-error {{does not match}}
void ; // expected-note {{previous}}
// FIXME: The missing exception specification that we report here doesn't make
// sense in the context of this declaration.
void ; // expected-error {{missing exception specification 'noexcept(X)'}}