[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / ms-exception-spec.cpp
blobcf460356c97898b906d9db8a666efe276ec62793
1 // RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
2 // RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
4 // FIXME: Should -fms-compatibility soften these errors into warnings to match
5 // MSVC? In practice, MSVC never implemented dynamic exception specifiers, so
6 // there isn't much Windows code in the wild that uses them.
7 #if __cplusplus >= 201703L
8 // expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
9 // expected-note@+2 {{use 'noexcept(false)' instead}}
10 #endif
11 void f() throw(...) { }
13 namespace PR28080 {
14 struct S; // expected-note {{forward declaration}}
15 #if __cplusplus >= 201703L
16 // expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
17 // expected-note@+2 {{use 'noexcept(false)' instead}}
18 #endif
19 void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}}
20 void fn() throw(); // expected-warning {{does not match previous declaration}}
23 template <typename T> struct FooPtr {
24 template <typename U> FooPtr(U *p) : m_pT(nullptr) {}
26 template <>
27 // FIXME: It would be better if this note pointed at the primary template
28 // above.
29 // expected-note@+1 {{previous declaration is here}}
30 FooPtr(T *pInterface) throw() // expected-warning {{exception specification in declaration does not match previous declaration}}
31 : m_pT(pInterface) {}
33 T *m_pT;
35 struct Bar {};
36 template struct FooPtr<Bar>; // expected-note {{requested here}}