annotate clang/test/SemaCXX/ms-exception-spec.cpp @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 // FIXME: Should -fms-compatibility soften these errors into warnings to match
anatofuz
parents:
diff changeset
5 // MSVC? In practice, MSVC never implemented dynamic exception specifiers, so
anatofuz
parents:
diff changeset
6 // there isn't much Windows code in the wild that uses them.
anatofuz
parents:
diff changeset
7 #if __cplusplus >= 201703L
anatofuz
parents:
diff changeset
8 // expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
anatofuz
parents:
diff changeset
9 // expected-note@+2 {{use 'noexcept(false)' instead}}
anatofuz
parents:
diff changeset
10 #endif
anatofuz
parents:
diff changeset
11 void f() throw(...) { }
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 namespace PR28080 {
anatofuz
parents:
diff changeset
14 struct S; // expected-note {{forward declaration}}
anatofuz
parents:
diff changeset
15 #if __cplusplus >= 201703L
anatofuz
parents:
diff changeset
16 // expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}}
anatofuz
parents:
diff changeset
17 // expected-note@+2 {{use 'noexcept(false)' instead}}
anatofuz
parents:
diff changeset
18 #endif
anatofuz
parents:
diff changeset
19 void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}}
anatofuz
parents:
diff changeset
20 void fn() throw(); // expected-warning {{does not match previous declaration}}
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 template <typename T> struct FooPtr {
anatofuz
parents:
diff changeset
24 template <typename U> FooPtr(U *p) : m_pT(nullptr) {}
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 template <>
anatofuz
parents:
diff changeset
27 // FIXME: It would be better if this note pointed at the primary template
anatofuz
parents:
diff changeset
28 // above.
anatofuz
parents:
diff changeset
29 // expected-note@+1 {{previous declaration is here}}
anatofuz
parents:
diff changeset
30 FooPtr(T *pInterface) throw() // expected-warning {{exception specification in declaration does not match previous declaration}}
anatofuz
parents:
diff changeset
31 : m_pT(pInterface) {}
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 T *m_pT;
anatofuz
parents:
diff changeset
34 };
anatofuz
parents:
diff changeset
35 struct Bar {};
anatofuz
parents:
diff changeset
36 template struct FooPtr<Bar>; // expected-note {{requested here}}