[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 4 13:44:16 PST 2023
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/74373
This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details.
>From 1e5ede1925b8cfdae93415abfddb930aaaf3241e Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Tue, 5 Dec 2023 00:37:51 +0300
Subject: [PATCH] [clang][NFC] Refactor expected directives in C++ DRs 500-599
This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details.
---
clang/test/CXX/drs/dr5xx.cpp | 595 +++++++++++++++++++++--------------
1 file changed, 361 insertions(+), 234 deletions(-)
diff --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index 204d07f04f4e5..21a6646d4abcf 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -1,20 +1,21 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-11,cxx98-14,cxx98-17,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-11,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx17,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx23,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// FIXME: This is included to avoid a diagnostic with no source location
// pointing at the implicit operator new. We can't match such a diagnostic
// with -verify.
__extension__ typedef __SIZE_TYPE__ size_t;
-void *operator new(size_t); // expected-error 0-1{{missing exception spec}} expected-note{{candidate}}
+void *operator new(size_t); // #dr5xx-global-operator-new
+// cxx98-error at -1 {{'operator new' is missing exception specification 'throw(std::bad_alloc)'}}
#if __cplusplus > 201402L
namespace std {
enum class align_val_t : size_t {};
}
-void *operator new(size_t, std::align_val_t); // expected-note{{candidate}}
+void *operator new(size_t, std::align_val_t); // #dr5xx-global-operator-new-aligned
#endif
namespace dr500 { // dr500: dup 372
@@ -33,7 +34,8 @@ namespace dr501 { // dr501: yes
struct A {
friend void f() {}
void g() {
- void (*p)() = &f; // expected-error {{undeclared identifier}}
+ void (*p)() = &f;
+ // expected-error at -1 {{use of undeclared identifier 'f'}}
}
};
}
@@ -45,7 +47,8 @@ namespace dr502 { // dr502: yes
void q1() { f(e); }
void q2() { Q arr[sizeof(E)]; f(arr); }
void q3() { Q arr[e]; f(arr); }
- void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared identifier 'f'}}
+ void sanity() { Q arr[1]; f(arr); }
+ // expected-error at -1 {{use of undeclared identifier 'f'}}
};
int f(A<int>::E);
template<int N> int f(Q (&)[N]);
@@ -53,14 +56,22 @@ namespace dr502 { // dr502: yes
}
namespace dr505 { // dr505: yes
- const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard escape}}
- const char *unknown = "\Q"; // expected-error {{unknown escape sequence}}
+ const char *exts = "\e\(\{\[\%";
+ // expected-error at -1 {{use of non-standard escape character '\e'}}
+ // expected-error at -2 {{use of non-standard escape character '\('}}
+ // expected-error at -3 {{use of non-standard escape character '\{'}}
+ // expected-error at -4 {{use of non-standard escape character '\['}}
+ // expected-error at -5 {{use of non-standard escape character '\%'}}
+ const char *unknown = "\Q";
+ // expected-error at -1 {{unknown escape sequence '\Q'}}
}
namespace dr506 { // dr506: yes
struct NonPod { ~NonPod(); };
void f(...);
- void g(NonPod np) { f(np); } // expected-error {{cannot pass}}
+ void g(NonPod np) { f(np); }
+ // cxx98-error at -1 {{cannot pass object of non-POD type 'NonPod' through variadic function; call will abort at runtime}}
+ // since-cxx11-error at -2 {{cannot pass object of non-trivial type 'NonPod' through variadic function; call will abort at runtime}}
}
// FIXME: Add tests here once DR260 is resolved.
@@ -71,15 +82,13 @@ namespace dr506 { // dr506: yes
// dr510: na
namespace dr512 { // dr512: yes
- struct A {
- A(int);
+ struct A { // #dr512-A
+ A(int); // #dr512-A-ctor
};
union U { A a; };
-#if __cplusplus < 201103L
- // expected-error at -2 {{has a non-trivial default constructor}}
- // expected-note at -6 {{no default constructor}}
- // expected-note at -6 {{suppressed by user-declared constructor}}
-#endif
+ // cxx98-error at -1 {{union member 'a' has a non-trivial default constructor}}
+ // cxx98-note@#dr512-A {{because type 'dr512::A' has no default constructor}}
+ // cxx98-note@#dr512-A-ctor {{implicit default constructor suppressed by user-declared constructor}}
}
// dr513: na
@@ -101,9 +110,7 @@ namespace dr515 { // dr515: sup 1017
struct A { int a; };
struct B { void f() { int k = sizeof(A::a); } };
-#if __cplusplus < 201103L
- // expected-error at -2 {{invalid use of non-static data member}}
-#endif
+ // cxx98-error at -1 {{invalid use of non-static data member 'a'}}
}
// dr516: na
@@ -111,7 +118,8 @@ namespace dr515 { // dr515: sup 1017
namespace dr517 { // dr517: no
// This is NDR, but we should diagnose it anyway.
template<typename T> struct S {};
- template<typename T> int v = 0; // expected-error 0-1{{extension}}
+ template<typename T> int v = 0;
+ // cxx98-11-error at -1 {{variable templates are a C++14 extension}}
template struct S<int*>;
template int v<int*>;
@@ -121,18 +129,16 @@ namespace dr517 { // dr517: no
// FIXME: These are both ill-formed.
template<typename T> struct S<T*> {};
- template<typename T> int v<T*> = 0; // expected-error 0-1{{extension}}
+ template<typename T> int v<T*> = 0;
// FIXME: These are both ill-formed.
template<typename T> struct S<T&> {};
- template<typename T> int v<T&> = 0; // expected-error 0-1{{extension}}
+ template<typename T> int v<T&> = 0;
}
namespace dr518 { // dr518: yes c++11
enum E { e, };
-#if __cplusplus < 201103L
- // expected-error at -2 {{C++11 extension}}
-#endif
+ // cxx98-error at -1 {{commas at the end of enumerator lists are a C++11 extension}}
}
namespace dr519 { // dr519: yes
@@ -156,7 +162,7 @@ namespace dr522 { // dr522: yes
template<typename T> void b2(volatile T * const *);
template<typename T> void b2(volatile T * const S::*);
template<typename T> void b2(volatile T * const S::* const *);
- template<typename T> void b2a(volatile T *S::* const *); // expected-note {{candidate template ignored: deduced type 'volatile int *dr522::S::*const *' of 1st parameter does not match adjusted type 'int *dr522::S::**' of argument}}
+ template<typename T> void b2a(volatile T *S::* const *); // #dr522-b2a
template<typename T> struct Base {};
struct Derived : Base<int> {};
@@ -174,22 +180,27 @@ namespace dr522 { // dr522: yes
b2(pm);
b2(a);
b2(am);
- b2a(am); // expected-error {{no matching function}}
+ b2a(am);
+ // expected-error at -1 {{no matching function for call to 'b2a'}}
+ // expected-note@#dr522-b2a {{candidate template ignored: deduced type 'volatile int *dr522::S::*const *' of 1st parameter does not match adjusted type 'int *dr522::S::**' of argument}}
b3(d);
b3(cd);
}
}
namespace dr524 { // dr524: yes
- template<typename T> void f(T a, T b) { operator+(a, b); } // expected-error {{call}}
+ template<typename T> void f(T a, T b) { operator+(a, b); }
+ // expected-error at -1 {{call to function 'operator+' that is neither visible in the template definition nor found by argument-dependent lookup}}
+ // expected-note@#dr524-f-N-S {{in instantiation of function template specialization 'dr524::f<dr524::N::S>' requested here}}
+ // expected-note@#dr524-operator-plus {{'operator+' should be declared prior to the call site or in namespace 'dr524::N'}}
struct S {};
void operator+(S, S);
template void f(S, S);
namespace N { struct S {}; }
- void operator+(N::S, N::S); // expected-note {{should be declared}}
- template void f(N::S, N::S); // expected-note {{instantiation}}
+ void operator+(N::S, N::S); // #dr524-operator-plus
+ template void f(N::S, N::S); // #dr524-f-N-S
}
namespace dr525 { // dr525: yes
@@ -202,9 +213,11 @@ namespace dr525 { // dr525: yes
}
}
namespace after {
- template <class T> struct D { typename T::error e; }; // expected-error {{prior to '::'}}
+ template <class T> struct D { typename T::error e; };
+ // expected-error at -1 {{type 'double' cannot be used prior to '::' because it has no members}}
+ // expected-note@#dr525-ppp {{in instantiation of template class 'dr525::after::D<double>' requested here}}
void g(D<double> *ppp) {
- delete ppp; // expected-note {{instantiation of}}
+ delete ppp; // #dr525-ppp
}
}
}
@@ -212,30 +225,36 @@ namespace dr525 { // dr525: yes
namespace dr526 { // dr526: yes
template<int> struct S {};
template<int N> void f1(S<N> s);
- template<int N> void f2(S<(N)> s); // expected-note {{couldn't infer}}
- template<int N> void f3(S<+N> s); // expected-note {{couldn't infer}}
+ template<int N> void f2(S<(N)> s); // #dr526-f2
+ template<int N> void f3(S<+N> s); // #dr526-f3
template<int N> void g1(int (&)[N]);
- template<int N> void g2(int (&)[(N)]); // expected-note {{couldn't infer}}
- template<int N> void g3(int (&)[+N]); // expected-note {{couldn't infer}}
+ template<int N> void g2(int (&)[(N)]); // #dr526-g2
+ template<int N> void g3(int (&)[+N]); // #dr526-g3
void test(int (&a)[3], S<3> s) {
f1(s);
- f2(s); // expected-error {{no matching}}
- f3(s); // expected-error {{no matching}}
+ f2(s);
+ // expected-error at -1 {{no matching function for call to 'f2'}}
+ // expected-note@#dr526-f2 {{candidate template ignored: couldn't infer template argument 'N'}}
+ f3(s);
+ // expected-error at -1 {{no matching function for call to 'f3'}}
+ // expected-note@#dr526-f3 {{candidate template ignored: couldn't infer template argument 'N'}}
g1(a);
- g2(a); // expected-error {{no matching}}
- g3(a); // expected-error {{no matching}}
+ g2(a);
+ // expected-error at -1 {{no matching function for call to 'g2'}}
+ // expected-note@#dr526-g2 {{candidate template ignored: couldn't infer template argument 'N'}}
+ g3(a);
+ // expected-error at -1 {{no matching function for call to 'g3'}}
+ // expected-note@#dr526-g3 {{candidate template ignored: couldn't infer template argument 'N'}}
}
template<int N> struct X {
typedef int type;
X<N>::type v1;
X<(N)>::type v2;
+ // cxx98-17-error at -1 {{missing 'typename' prior to dependent type name X<(N)>::type; implicit 'typename' is a C++20 extension}}
X<+N>::type v3;
-#if __cplusplus <= 201703L
- // expected-error at -3 {{implicit 'typename' is a C++20 extension}}
- // expected-error at -3 {{implicit 'typename' is a C++20 extension}}
-#endif
+ // cxx98-17-error at -1 {{missing 'typename' prior to dependent type name X<+N>::type; implicit 'typename' is a C++20 extension}}
};
}
@@ -307,32 +326,48 @@ namespace dr531 { // dr531: partial
void f(T) { T::error; }
template<typename U> void g(T, U) { T::error; }
struct B { typename T::error error; };
- template<typename U> struct C { typename T::error error; }; // expected-note {{here}}
+ template<typename U> struct C { typename T::error error; }; // #dr531-C
static T n;
};
template<typename T> T A<T>::n = T::error;
- void A<int>::f(int) {} // expected-error {{requires 'template<>'}}
- template<typename U> void A<int>::g(int, U) {} // expected-error {{should be empty}}
- struct A<int>::B {}; // expected-error {{requires 'template<>'}}
- template<typename U> struct A<int>::C {}; // expected-error {{should be empty}} expected-error {{different kind of symbol}}
- int A<int>::n = 0; // expected-error {{requires 'template<>'}}
-
- template<> struct A<char> { // expected-note 2{{here}}
+ void A<int>::f(int) {}
+ // expected-error at -1 {{template specialization requires 'template<>'}}
+ template<typename U> void A<int>::g(int, U) {}
+ // expected-error at -1 {{template parameter list matching the non-templated nested type 'dr531::bad::A<int>' should be empty}}
+ struct A<int>::B {};
+ // expected-error at -1 {{template specialization requires 'template<>'}}
+ template<typename U> struct A<int>::C {};
+ // expected-error at -1 {{template parameter list matching the non-templated nested type 'dr531::bad::A<int>' should be empty}}
+ // expected-error at -2 {{redefinition of 'C' as different kind of symbol}}
+ // expected-note@#dr531-C {{previous definition is here}}
+ int A<int>::n = 0;
+ // expected-error at -1 {{template specialization requires 'template<>'}}
+
+ template<> struct A<char> { // #dr531-A-char
void f(char);
template<typename U> void g(char, U);
- struct B; // expected-note {{here}}
+ struct B; // #dr531-B
template<typename U> struct C;
static char n;
};
- template<> void A<char>::f(char) {} // expected-error {{no function template matches}}
+ template<> void A<char>::f(char) {}
+ // expected-error at -1 {{no function template matches function template specialization 'f'}}
// FIXME: This is ill-formed; -pedantic-errors should reject.
- template<> template<typename U> void A<char>::g(char, U) {} // expected-warning {{extraneous template parameter list}}
- template<> struct A<char>::B {}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}}
+ template<> template<typename U> void A<char>::g(char, U) {}
+ // expected-warning at -1 {{extraneous template parameter list in template specialization}}
+ // expected-note@#dr531-A-char {{'template<>' header not required for explicitly-specialized class 'dr531::bad::A<char>' declared here}}
+ template<> struct A<char>::B {};
+ // expected-error at -1 {{extraneous 'template<>' in declaration of struct 'B'}}
+ // expected-error at -2 {{specialization of member 'dr531::bad::A<char>::B' does not specialize an instantiated member}}
+ // expected-note@#dr531-B {{attempt to specialize declaration here}}
// FIXME: This is ill-formed; -pedantic-errors should reject.
- template<> template<typename U> struct A<char>::C {}; // expected-warning {{extraneous template parameter list}}
- template<> char A<char>::n = 0; // expected-error {{extraneous 'template<>'}}
+ template<> template<typename U> struct A<char>::C {};
+ // expected-warning at -1 {{extraneous template parameter list in template specialization}}
+ // expected-note@#dr531-A-char {{'template<>' header not required for explicitly-specialized class 'dr531::bad::A<char>' declared here}}
+ template<> char A<char>::n = 0;
+ // expected-error at -1 {{extraneous 'template<>' in declaration of variable 'n'}}
}
namespace nested {
@@ -346,10 +381,12 @@ namespace dr531 { // dr531: partial
template<typename V> void i();
};
template<> template<typename U> void A<int>::B<U>::f() {}
- template<typename U> void A<int>::B<U>::g() {} // expected-error {{should be empty}}
+ template<typename U> void A<int>::B<U>::g() {}
+ // expected-error at -1 {{template parameter list matching the non-templated nested type 'dr531::nested::A<int>' should be empty ('template<>')}}
template<> template<typename U> template<typename V> void A<int>::B<U>::h() {}
- template<typename U> template<typename V> void A<int>::B<U>::i() {} // expected-error {{should be empty}}
+ template<typename U> template<typename V> void A<int>::B<U>::i() {}
+ // expected-error at -1 {{template parameter list matching the non-templated nested type 'dr531::nested::A<int>' should be empty ('template<>')}}
#if __cplusplus <= 201703L
// FIXME: All of those declarations shouldn't crash in C++20 mode.
@@ -357,8 +394,10 @@ namespace dr531 { // dr531: partial
template<> template<> template<typename V> void A<int>::B<int>::h() {}
template<> template<> template<> void A<int>::B<int>::h<int>() {}
- template<> void A<int>::B<char>::f() {} // expected-error {{requires 'template<>'}}
- template<> template<typename V> void A<int>::B<char>::h() {} // expected-error {{should be empty}}
+ template<> void A<int>::B<char>::f() {}
+ // cxx98-17-error at -1 {{template specialization requires 'template<>'}}
+ template<> template<typename V> void A<int>::B<char>::h() {}
+ // cxx98-17-error at -1 {{template parameter list matching the non-templated nested type 'dr531::nested::A<int>::B<char>' should be empty ('template<>')}}
#endif
}
}
@@ -384,7 +423,8 @@ namespace dr532 { // dr532: 3.5
namespace dr534 { // dr534: 2.9
struct S {};
template<typename T> void operator+(S, T);
- template<typename T> void operator+<T*>(S, T*) {} // expected-error {{function template partial spec}}
+ template<typename T> void operator+<T*>(S, T*) {}
+ // expected-error at -1 {{function template partial specialization is not allowed}}
}
namespace dr535 { // dr535: yes
@@ -423,43 +463,70 @@ namespace dr535 { // dr535: yes
// dr538: na
// dr539: yes
-const dr539( // expected-error {{a type specifier is required}}
- const a) { // expected-error {{unknown type name 'a'}}
- const b; // expected-error {{a type specifier is required}}
- new const; // expected-error {{expected a type}}
- try {} catch (const n) {} // expected-error {{unknown type name 'n'}}
- try {} catch (const) {} // expected-error {{expected a type}}
- if (const n = 0) {} // expected-error {{a type specifier is required}}
- switch (const n = 0) {} // expected-error {{a type specifier is required}}
- while (const n = 0) {} // expected-error {{a type specifier is required}}
- for (const n = 0; // expected-error {{a type specifier is required}}
- const m = 0; ) {} // expected-error {{a type specifier is required}}
- sizeof(const); // expected-error {{a type specifier is required}}
+const dr539(
+// expected-error at -1 {{a type specifier is required for all declarations}}
+ const a) {
+ // expected-error at -1 {{unknown type name 'a'}}
+ const b;
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ new const;
+ // expected-error at -1 {{expected a type}}
+ try {} catch (const n) {}
+ // expected-error at -1 {{unknown type name 'n'}}
+ try {} catch (const) {}
+ // expected-error at -1 {{expected a type}}
+ if (const n = 0) {}
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ switch (const n = 0) {}
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ while (const n = 0) {}
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ for (const n = 0;
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ const m = 0; ) {}
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ sizeof(const);
+ // expected-error at -1 {{a type specifier is required for all declarations}}
struct S {
- const n; // expected-error {{a type specifier is required}}
- operator const(); // expected-error {{expected a type}}
+ const n;
+ // expected-error at -1 {{a type specifier is required for all declarations}}
+ operator const();
+ // expected-error at -1 {{expected a type}}
};
#if __cplusplus >= 201103L
int arr[3];
// FIXME: The extra braces here are to avoid the parser getting too
// badly confused when recovering here. We should fix this recovery.
- { for (const n // expected-error {{unknown type name 'n'}} expected-note {{}}
- : arr) ; {} } // expected-error +{{}}
- (void) [](const) {}; // expected-error {{a type specifier is required}}
- (void) [](const n) {}; // expected-error {{unknown type name 'n'}}
- enum E : const {}; // expected-error {{expected a type}}
- using T = const; // expected-error {{expected a type}}
- auto f() -> const; // expected-error {{expected a type}}
+ { for (const n
+ // since-cxx11-error at -1 {{unknown type name 'n'}}
+ // since-cxx11-note at -2 {{}}
+ : arr) ; {} }
+ // since-cxx11-error at -1 +{{}}
+ (void) [](const) {};
+ // since-cxx11-error at -1 {{a type specifier is required for all declarations}}
+ (void) [](const n) {};
+ // since-cxx11-error at -1 {{unknown type name 'n'}}
+ enum E : const {};
+ // since-cxx11-error at -1 {{expected a type}}
+ using T = const;
+ // since-cxx11-error at -1 {{expected a type}}
+ auto f() -> const;
+ // since-cxx11-error at -1 {{expected a type}}
#endif
}
namespace dr540 { // dr540: yes
typedef int &a;
- typedef const a &a; // expected-warning {{has no effect}}
+ typedef const a &a;
+ // expected-warning at -1 {{'const' qualifier on reference type 'a' (aka 'int &') has no effect}}
typedef const int &b;
typedef b &b;
- typedef const a &c; // expected-note {{previous}} expected-warning {{has no effect}}
- typedef const b &c; // expected-error {{different}} expected-warning {{has no effect}}
+ typedef const a &c; // #dr540-typedef-a-c
+ // expected-warning at -1 {{'const' qualifier on reference type 'a' (aka 'int &') has no effect}}
+ typedef const b &c; // #dr540-typedef-b-c
+ // expected-error@#dr540-typedef-b-c {{typedef redefinition with different types ('const int &' vs 'int &')}}
+ // expected-note@#dr540-typedef-a-c {{previous definition is here}}
+ // expected-warning@#dr540-typedef-b-c {{'const' qualifier on reference type 'b' (aka 'const int &') has no effect}}
}
namespace dr541 { // dr541: yes
@@ -476,9 +543,15 @@ namespace dr541 { // dr541: yes
void x() {
// These are type-dependent expressions, even though we could
// determine that all calls have type 'int'.
- X<sizeof(f(0))>::type a; // expected-error +{{}}
- X<sizeof(g(0))>::type b; // expected-error +{{}}
- X<sizeof(h(0))>::type b; // expected-error +{{}}
+ X<sizeof(f(0))>::type a;
+ // expected-error at -1 {{expected ';' after expression}}
+ // expected-error at -2 {{use of undeclared identifier 'a'}}
+ X<sizeof(g(0))>::type b;
+ // expected-error at -1 {{expected ';' after expression}}
+ // expected-error at -2 {{use of undeclared identifier 'b'}}
+ X<sizeof(h(0))>::type b;
+ // expected-error at -1 {{expected ';' after expression}}
+ // expected-error at -2 {{use of undeclared identifier 'b'}}
typename X<sizeof(f(0))>::type a;
typename X<sizeof(h(0))>::type b;
@@ -490,24 +563,21 @@ namespace dr542 { // dr542: yes
#if __cplusplus >= 201103L
// In C++20 A and B are no longer aggregates and thus the constructor is
// called, which fails.
- struct A { A() = delete; int n; };
- A a[32] = {}; // ok, constructor not called
-#if __cplusplus > 201703L
- // expected-error at -2 {{call to deleted constructor}}
- // expected-note at -3 {{in implicit initialization}}
- // expected-note at -5 {{marked deleted here}}
-#endif
+ struct A { A() = delete; int n; }; // #dr542-A
+ // ok, constructor not called
+ A a[32] = {}; // #dr542-a
+ // since-cxx20-error at -1 {{call to deleted constructor of 'A'}}
+ // since-cxx20-note@#dr542-A {{'A' has been explicitly marked deleted here}}
+ // since-cxx20-note@#dr542-a {{in implicit initialization of array element 0 with omitted initializer}}
struct B {
int n;
private:
- B() = default;
+ B() = default; // #dr542-B-ctor
};
B b[32] = {}; // ok, constructor not called
-#if __cplusplus > 201703L
- // expected-error at -2 {{calling a private constructor}}
- // expected-note at -5 {{declared private here}}
-#endif
+ // since-cxx20-error at -1 {{calling a private constructor of class 'dr542::B'}}
+ // since-cxx20-note@#dr542-B-ctor {{declared private here}}
#endif
}
@@ -520,13 +590,11 @@ namespace dr543 { // dr543: 3.0
// deleted, and value-initialization *does* call a deleted default
// constructor, even if it is trivial.
struct A {
- const int n;
+ const int n; // #dr543-A-n
};
A a = A();
-#if __cplusplus >= 201103L
- // expected-error at -2 {{deleted}}
- // expected-note at -5 {{would not be initialized}}
-#endif
+ // since-cxx11-error at -1 {{call to implicitly-deleted default constructor of 'A'}}
+ // since-cxx11-note@#dr543-A-n {{default constructor of 'A' is implicitly deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
}
namespace dr544 { // dr544: yes
@@ -564,23 +632,17 @@ namespace dr551 { // dr551: yes c++11
// FIXME: This obviously should apply in C++98 mode too.
template<typename T> void f() {}
template inline void f<int>();
-#if __cplusplus >= 201103L
- // expected-error at -2 {{cannot be 'inline'}}
-#endif
+ // since-cxx11-error at -1 {{explicit instantiation cannot be 'inline'}}
template<typename T> inline void g() {}
template inline void g<int>();
-#if __cplusplus >= 201103L
- // expected-error at -2 {{cannot be 'inline'}}
-#endif
+ // since-cxx11-error at -1 {{explicit instantiation cannot be 'inline'}}
template<typename T> struct X {
void f() {}
};
template inline void X<int>::f();
-#if __cplusplus >= 201103L
- // expected-error at -2 {{cannot be 'inline'}}
-#endif
+ // since-cxx11-error at -1 {{explicit instantiation cannot be 'inline'}}
}
namespace dr552 { // dr552: yes
@@ -597,10 +659,14 @@ namespace dr553 {
// Contrary to the apparent intention of the DR, operator new is not actually
// looked up with a lookup mechanism that performs ADL; the standard says it
// "is looked up in global scope", where it is not visible.
- void *p = new (c) int; // expected-error {{no matching function}}
+ void *p = new (c) int;
+ // expected-error at -1 {{no matching function for call to 'operator new'}}
+ // since-cxx17-note@#dr5xx-global-operator-new-aligned {{candidate function not viable: no known conversion from 'dr553_class' to 'std::align_val_t' for 2nd argument}}
+ // expected-note@#dr5xx-global-operator-new {{candidate function not viable: requires 1 argument, but 2 were provided}}
struct namespace_scope {
- friend void *operator new(size_t, namespace_scope); // expected-error {{cannot be declared inside a namespace}}
+ friend void *operator new(size_t, namespace_scope);
+ // expected-error at -1 {{'operator new' cannot be declared inside a namespace}}
};
}
@@ -621,9 +687,11 @@ namespace dr557 { // dr557: 3.1
namespace dr558 { // dr558: 2.9
wchar_t a = L'\uD7FF';
wchar_t b = L'\xD7FF';
- wchar_t c = L'\uD800'; // expected-error {{invalid universal character}}
+ wchar_t c = L'\uD800';
+ // expected-error at -1 {{invalid universal character}}
wchar_t d = L'\xD800';
- wchar_t e = L'\uDFFF'; // expected-error {{invalid universal character}}
+ wchar_t e = L'\uDFFF';
+ // expected-error at -1 {{invalid universal character}}
wchar_t f = L'\xDFFF';
wchar_t g = L'\uE000';
wchar_t h = L'\xE000';
@@ -656,14 +724,18 @@ namespace dr564 { // dr564: yes
namespace dr565 { // dr565: yes
namespace N {
- template<typename T> int f(T); // expected-note {{target}}
+ template<typename T> int f(T); // #dr565-f
}
- using N::f; // expected-note {{using}}
+ using N::f; // #dr565-using
template<typename T> int f(T*);
template<typename T> void f(T);
- template<typename T, int = 0> int f(T); // expected-error 0-1{{extension}}
+ template<typename T, int = 0> int f(T);
+ // cxx98-error at -1 {{default template arguments for a function template are a C++11 extension}}
template<typename T> int f(T, int = 0);
- template<typename T> int f(T); // expected-error {{conflicts with}}
+ template<typename T> int f(T);
+ // expected-error at -1 {{declaration conflicts with target of using declaration already in scope}}
+ // expected-note@#dr565-f {{target of using declaration}}
+ // expected-note@#dr565-using {{using declaration}}
}
namespace dr566 { // dr566: yes
@@ -704,17 +776,13 @@ namespace dr568 { // dr568: 3.0 c++11
void f(...);
void g(trivial t) { f(t); }
-#if __cplusplus < 201103L
- // expected-error at -2 {{non-POD}}
-#endif
+ // cxx98-error at -1 {{cannot pass object of non-POD type 'trivial' through variadic function; call will abort at runtime}}
void jump() {
goto x;
-#if __cplusplus < 201103L
- // expected-error at -2 {{cannot jump}}
- // expected-note at +2 {{non-POD}}
-#endif
- trivial t;
+ // cxx98-error at -1 {{cannot jump from this goto statement to its label}}
+ // cxx98-note@#dr568-t {{jump bypasses initialization of non-POD variable}}
+ trivial t; // #dr568-t
x: ;
}
}
@@ -723,22 +791,24 @@ namespace dr569 { // dr569: yes c++11
// FIXME: This is a DR issue against C++98, so should probably apply there
// too.
;;;;;
-#if __cplusplus < 201103L
- // expected-error at -2 {{C++11 extension}}
-#endif
+ // cxx98-error at -1 {{C++11 extension}}
}
namespace dr570 { // dr570: dup 633
int n;
- int &r = n; // expected-note {{previous}}
- int &r = n; // expected-error {{redefinition}}
+ int &r = n; // #dr570-r
+ int &r = n;
+ // expected-error at -1 {{redefinition of 'r'}}
+ // expected-note@#dr570-r {{previous definition is here}}
}
namespace dr571 { // dr571 unknown
// FIXME: Add a codegen test.
typedef int &ir;
int n;
- const ir r = n; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage.
+ // FIXME: Test if this has internal linkage.
+ const ir r = n;
+ // expected-warning at -1 {{'const' qualifier on reference type 'ir' (aka 'int &') has no effect}}
}
namespace dr572 { // dr572: yes
@@ -750,13 +820,13 @@ namespace dr573 { // dr573: no
void *a;
int *b = reinterpret_cast<int*>(a);
void (*c)() = reinterpret_cast<void(*)()>(a);
+ // cxx98-error at -1 {{cast between pointer-to-function and pointer-to-object is an extension}}
void *d = reinterpret_cast<void*>(c);
-#if __cplusplus < 201103L
- // expected-error at -3 {{extension}}
- // expected-error at -3 {{extension}}
-#endif
- void f() { delete a; } // expected-error {{cannot delete}}
- int n = d - a; // expected-error {{arithmetic on pointers to void}}
+ // cxx98-error at -1 {{cast between pointer-to-function and pointer-to-object is an extension}}
+ void f() { delete a; }
+ // expected-error at -1 {{cannot delete expression with pointer-to-'void' type 'void *'}}
+ int n = d - a;
+ // expected-error at -1 {{arithmetic on pointers to void}}
// FIXME: This is ill-formed.
template<void*> struct S;
template<int*> struct T;
@@ -764,62 +834,80 @@ namespace dr573 { // dr573: no
namespace dr574 { // dr574: 3.0
struct A {
- A &operator=(const A&) const; // expected-note {{different qualifiers}}
+ A &operator=(const A&) const; // #dr574-A-copy-assign
};
struct B {
- B &operator=(const B&) volatile; // expected-note {{different qualifiers}}
+ B &operator=(const B&) volatile; // #dr574-B-copy-assign
};
#if __cplusplus >= 201103L
struct C {
- C &operator=(const C&) &; // #574-overload1 \
- // expected-note {{not viable}} \
- // expected-note {{here}}
-
+ C &operator=(const C&) &; // #dr574-C-copy-assign
};
struct D {
- D &operator=(const D&) &&; // #574-overload2 \
- // expected-note {{not viable}} \
- // expected-note {{here}}
+ D &operator=(const D&) &&; // #dr574-D-copy-assign
};
void test(C c, D d) {
c = c;
- C() = c; // expected-error {{no viable}}
- d = d; // expected-error {{no viable}}
+ C() = c;
+ // since-cxx11-error at -1 {{no viable overloaded '='}}
+ // since-cxx11-note@#dr574-C-copy-assign {{candidate function not viable: expects an lvalue for object argument}}
+ d = d;
+ // since-cxx11-error at -1 {{no viable overloaded '='}}
+ // since-cxx11-note@#dr574-D-copy-assign {{candidate function not viable: expects an rvalue for object argument}}
D() = d;
}
#endif
struct Test {
- friend A &A::operator=(const A&); // expected-error {{does not match}}
- friend B &B::operator=(const B&); // expected-error {{does not match}}
+ friend A &A::operator=(const A&);
+ // expected-error at -1 {{friend declaration of 'operator=' does not match any declaration in 'dr574::A'}}
+ // expected-note@#dr574-A-copy-assign {{candidate function has different qualifiers (expected unqualified but found 'const')}}
+ friend B &B::operator=(const B&);
+ // expected-error at -1 {{friend declaration of 'operator=' does not match any declaration in 'dr574::B'}}
+ // expected-note@#dr574-B-copy-assign {{candidate function has different qualifiers (expected unqualified but found 'volatile')}}
#if __cplusplus >= 202302L
- friend C &C::operator=(const C&); // expected-error {{conflicting types for 'operator='}}
- friend D &D::operator=(const D&); // expected-error {{conflicting types for 'operator='}} __cplusplus >= 201103L
+ friend C &C::operator=(const C&);
+ // since-cxx23-error at -1 {{conflicting types for 'operator='}}
+ // since-cxx23-note@#dr574-C-copy-assign {{previous declaration is here}}
+ friend D &D::operator=(const D&);
+ // since-cxx23-error at -1 {{conflicting types for 'operator='}}
+ // since-cxx23-note@#dr574-D-copy-assign {{previous declaration is here}}
#elif __cplusplus >= 201103L
// FIXME: We shouldn't produce the 'cannot overload' diagnostics here.
- friend C &C::operator=(const C&); // expected-error {{does not match}} \
- // expected-error {{cannot overload}} \
- // expected-note@#574-overload1 {{candidate}}
- friend D &D::operator=(const D&); // expected-error {{does not match}} \
- // expected-error {{cannot overload}} \
- // expected-note@#574-overload2 {{candidate}}
+ friend C &C::operator=(const C&); // #dr574-test-C
+ // since-cxx11-error@#dr574-test-C {{cannot overload}}
+ // since-cxx11-note@#dr574-C-copy-assign {{previous declaration is here}}
+ // since-cxx11-error@#dr574-test-C {{friend declaration of 'operator=' does not match any declaration in 'dr574::C'}}
+ // since-cxx11-note@#dr574-C-copy-assign {{candidate function}}
+ friend D &D::operator=(const D&); // #dr574-test-D
+ // since-cxx11-error@#dr574-test-D {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&&'}}
+ // since-cxx11-note@#dr574-D-copy-assign {{previous declaration is here}}
+ // since-cxx11-error@#dr574-test-D {{friend declaration of 'operator=' does not match any declaration in 'dr574::D'}}
+ // since-cxx11-note@#dr574-D-copy-assign {{candidate function}}
#endif
};
}
namespace dr575 { // dr575: yes
- template<typename T, typename U = typename T::type> void a(T); void a(...); // expected-error 0-1{{extension}}
- template<typename T, typename T::type U = 0> void b(T); void b(...); // expected-error 0-1{{extension}}
- template<typename T, int U = T::value> void c(T); void c(...); // expected-error 0-1{{extension}}
- template<typename T> void d(T, int = T::value); void d(...); // expected-error {{cannot be used prior to '::'}}
+ template<typename T, typename U = typename T::type> void a(T); void a(...);
+ // cxx98-error at -1 {{default template arguments for a function template are a C++11 extension}}
+ template<typename T, typename T::type U = 0> void b(T); void b(...);
+ // cxx98-error at -1 {{default template arguments for a function template are a C++11 extension}}
+ template<typename T, int U = T::value> void c(T); void c(...);
+ // cxx98-error at -1 {{default template arguments for a function template are a C++11 extension}}
+ template<typename T> void d(T, int = T::value); void d(...);
+ // expected-error at -1 {{type 'int' cannot be used prior to '::' because it has no members}}
+ // expected-note@#dr575-d {{in instantiation of default function argument expression for 'd<int>' required here}}
void x() {
a(0);
b(0);
c(0);
- d(0); // expected-note {{in instantiation of default function argument}}
+ d(0); // #dr575-d
}
- template<typename T = int&> void f(T* = 0); // expected-error 0-1{{extension}}
- template<typename T = int> void f(T = 0); // expected-error 0-1{{extension}}
+ template<typename T = int&> void f(T* = 0);
+ // cxx98-error at -1 {{default template arguments for a function template are a C++11 extension}}
+ template<typename T = int> void f(T = 0);
+ // cxx98-error at -1 {{default template arguments for a function template are a C++11 extension}}
void g() { f<>(); }
template<typename T> T &h(T *);
@@ -828,8 +916,10 @@ namespace dr575 { // dr575: yes
}
namespace dr576 { // dr576: 3.5
- typedef void f() {} // expected-error {{function definition declared 'typedef'}}
- void f(typedef int n); // expected-error {{invalid storage class}}
+ typedef void f() {}
+ // expected-error at -1 {{function definition declared 'typedef'}}
+ void f(typedef int n);
+ // expected-error at -1 {{invalid storage class specifier in function declarator}}
void f(char c) { typedef int n; }
}
@@ -837,22 +927,34 @@ namespace dr577 { // dr577: 3.5
typedef void V;
typedef const void CV;
void a(void);
- void b(const void); // expected-error {{qualifiers}}
+ void b(const void);
+ // expected-error at -1 {{'void' as parameter must not have type qualifiers}}
void c(V);
- void d(CV); // expected-error {{qualifiers}}
+ void d(CV);
+ // expected-error at -1 {{'void' as parameter must not have type qualifiers}}
void (*e)(void) = c;
- void (*f)(const void); // expected-error {{qualifiers}}
+ void (*f)(const void);
+ // expected-error at -1 {{'void' as parameter must not have type qualifiers}}
void (*g)(V) = a;
- void (*h)(CV); // expected-error {{qualifiers}}
- template<typename T> void i(T); // expected-note 2{{requires 1 arg}}
- template<typename T> void j(void (*)(T)); // expected-note 2{{argument may not have 'void' type}}
+ void (*h)(CV);
+ // expected-error at -1 {{'void' as parameter must not have type qualifiers}}
+ template<typename T> void i(T); // #dr577-i
+ template<typename T> void j(void (*)(T)); // #dr577-j
void k() {
a();
c();
- i<void>(); // expected-error {{no match}}
- i<const void>(); // expected-error {{no match}}
- j<void>(0); // expected-error {{no match}}
- j<const void>(0); // expected-error {{no match}}
+ i<void>();
+ // expected-error at -1 {{no matching function for call to 'i'}}
+ // expected-note@#dr577-i {{candidate function template not viable: requires 1 argument, but 0 were provided}}
+ i<const void>();
+ // expected-error at -1 {{no matching function for call to 'i'}}
+ // expected-note@#dr577-i {{candidate function template not viable: requires 1 argument, but 0 were provided}}
+ j<void>(0);
+ // expected-error at -1 {{no matching function for call to 'j'}}
+ // expected-note@#dr577-j {{candidate template ignored: substitution failure [with T = void]: argument may not have 'void' type}}
+ j<const void>(0);
+ // expected-error at -1 {{no matching function for call to 'j'}}
+ // expected-note@#dr577-j {{candidate template ignored: substitution failure [with T = const void]: argument may not have 'void' type}}
}
}
@@ -861,10 +963,10 @@ namespace dr580 { // dr580: partial
struct A { static C c; };
struct B { static C c; };
class C {
- C(); // expected-note {{here}}
- ~C(); // expected-note {{here}}
+ C(); // #dr580-C-ctor
+ ~C(); // #dr580-C-dtor
- typedef int I; // expected-note 2{{here}}
+ typedef int I; // #dr580-I
template<int> struct X;
template<int> friend struct Y;
template<int> void f();
@@ -874,7 +976,9 @@ namespace dr580 { // dr580: partial
template<C::I> struct C::X {};
template<C::I> struct Y {};
- template<C::I> struct Z {}; // expected-error {{private}}
+ template<C::I> struct Z {};
+ // expected-error at -1 {{'I' is a private member of 'dr580::C'}}
+ // expected-note@#dr580-I {{implicitly declared private here}}
struct C2 {
class X {
@@ -883,18 +987,25 @@ namespace dr580 { // dr580: partial
friend struct A;
};
class Y {
- template<X::I> struct A {}; // FIXME: We incorrectly accept this
- // because we think C2::Y::A<...> might
- // instantiate to C2::X::A
+ // FIXME: We incorrectly accept this
+ // because we think C2::Y::A<...> might
+ // instantiate to C2::X::A
+ template<X::I> struct A {};
};
};
template<C::I> void C::f() {}
template<C::I> void g() {}
- template<C::I> void h() {} // expected-error {{private}}
+ template<C::I> void h() {}
+ // expected-error at -1 {{'I' is a private member of 'dr580::C'}}
+ // expected-note@#dr580-I {{implicitly declared private here}}
C A::c;
- C B::c; // expected-error 2{{private}}
+ C B::c; // #dr580-c
+ // expected-error@#dr580-c {{calling a private constructor of class 'dr580::C'}}
+ // expected-note@#dr580-C-ctor {{implicitly declared private here}}
+ // expected-error@#dr580-c {{variable of type 'C' has private destructor}}
+ // expected-note@#dr580-C-dtor {{implicitly declared private here}}
}
// dr582: na
@@ -902,37 +1013,39 @@ namespace dr580 { // dr580: partial
namespace dr583 { // dr583: 4
// see n3624
int *p;
- bool b1 = p < 0; // expected-error {{ordered comparison between pointer and zero}}
- bool b2 = p > 0; // expected-error {{ordered comparison between pointer and zero}}
- bool b3 = p <= 0; // expected-error {{ordered comparison between pointer and zero}}
- bool b4 = p >= 0; // expected-error {{ordered comparison between pointer and zero}}
+ bool b1 = p < 0;
+ // expected-error at -1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
+ bool b2 = p > 0;
+ // expected-error at -1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
+ bool b3 = p <= 0;
+ // expected-error at -1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
+ bool b4 = p >= 0;
+ // expected-error at -1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
}
// dr584: na
namespace dr585 { // dr585: 3.0
- template<typename> struct T;
+ template<typename> struct T; // #dr585-struct-T
struct A {
friend T;
-#if __cplusplus <= 201402L
- // expected-error at -2 {{a type specifier is required}} expected-error at -2 {{can only be classes or functions}}
-#else
- // expected-error at -4 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}}
- // expected-note at -7 {{here}}
-#endif
+ // cxx98-14-error at -1 {{a type specifier is required for all declarations}}
+ // cxx98-14-error at -2 {{friends can only be classes or functions}}
+ // since-cxx17-error at -3 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}}
+ // since-cxx17-note@#dr585-struct-T {{template is declared here}}
// FIXME: It's not clear whether the standard allows this or what it means,
// but the DR585 writeup suggests it as an alternative.
- template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}
+ template<typename U> friend T<U>;
+ // expected-error at -1 {{friend type templates must use an elaborated type}}
};
- template<template<typename> class T> struct B {
+ template<template<typename> class T> struct B { // #dr585-template-T
friend T;
-#if __cplusplus <= 201402L
- // expected-error at -2 {{a type specifier is required}} expected-error at -2 {{can only be classes or functions}}
-#else
- // expected-error at -4 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}}
- // expected-note at -6 {{here}}
-#endif
- template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}
+ // cxx98-14-error at -1 {{a type specifier is required for all declarations}}
+ // cxx98-14-error at -2 {{friends can only be classes or functions}}
+ // since-cxx17-error at -3 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}}
+ // since-cxx17-note@#dr585-template-T {{template is declared here}}
+ template<typename U> friend T<U>;
+ // expected-error at -1 {{friend type templates must use an elaborated type}}
};
}
@@ -948,14 +1061,18 @@ namespace dr587 { // dr587: 3.2
}
namespace dr588 { // dr588: yes
- struct A { int n; }; // expected-note {{ambiguous}}
+ struct A { int n; }; // #dr588-A
template<typename T> int f() {
struct S : A, T { int f() { return n; } } s;
int a = s.f();
- int b = s.n; // expected-error {{found in multiple}}
+ int b = s.n;
+ // expected-error at -1 {{member 'n' found in multiple base classes of different types}}
+ // expected-note@#dr588-k {{in instantiation of function template specialization 'dr588::f<dr588::B>' requested here}}
+ // expected-note@#dr588-A {{member found by ambiguous name lookup}}
+ // expected-note@#dr588-B {{member found by ambiguous name lookup}}
}
- struct B { int n; }; // expected-note {{ambiguous}}
- int k = f<B>(); // expected-note {{here}}
+ struct B { int n; }; // #dr588-B
+ int k = f<B>(); // #dr588-k
}
namespace dr589 { // dr589: yes
@@ -964,8 +1081,10 @@ namespace dr589 { // dr589: yes
D f();
extern const B &b;
bool a;
- const B *p = &(a ? f() : b); // expected-error {{temporary}}
- const B *q = &(a ? D() : b); // expected-error {{temporary}}
+ const B *p = &(a ? f() : b);
+ // expected-error at -1 {{taking the address of a temporary object of type 'const B'}}
+ const B *q = &(a ? D() : b);
+ // expected-error at -1 {{taking the address of a temporary object of type 'const B'}}
}
namespace dr590 { // dr590: yes
@@ -990,7 +1109,8 @@ namespace dr591 { // dr591: no
template<typename T> struct A<T>::B::C : A<T> {
// FIXME: Should find member of non-dependent base class A<T>.
- M m; // expected-error {{incomplete type 'M' (aka 'void'}}
+ M m;
+ // expected-error at -1 {{field has incomplete type 'M' (aka 'void'}}
};
}
@@ -1001,9 +1121,8 @@ namespace dr591 { // dr591: no
namespace dr595 { // dr595: dup 1330
template<class T> struct X {
void f() throw(T) {}
-#if __cplusplus > 201402L
- // expected-error at -2 {{ISO C++17 does not allow}} expected-note at -2 {{use 'noexcept}}
-#endif
+ // since-cxx17-error at -1 {{ISO C++17 does not allow dynamic exception specifications}}
+ // since-cxx17-note at -2 {{use 'noexcept(false)' instead}}
};
struct S {
X<S> xs;
@@ -1029,7 +1148,8 @@ namespace dr598 { // dr598: yes
}
int &g(void(*)(char));
int &r = g(N::f);
- int &s = h(N::f); // expected-error {{undeclared}}
+ int &s = h(N::f);
+ // expected-error at -1 {{use of undeclared identifier 'h'}}
int &t = h(N::i);
}
@@ -1037,16 +1157,23 @@ namespace dr599 { // dr599: partial
typedef int Fn();
struct S { operator void*(); };
struct T { operator Fn*(); };
- struct U { operator int*(); operator void*(); }; // expected-note 2{{conversion}}
+ struct U { operator int*(); operator void*(); }; // #dr599-U
struct V { operator int*(); operator Fn*(); };
void f(void *p, void (*q)(), S s, T t, U u, V v) {
- delete p; // expected-error {{cannot delete}}
- delete q; // expected-error {{cannot delete}}
- delete s; // expected-error {{cannot delete}}
- delete t; // expected-error {{cannot delete}}
+ delete p;
+ // expected-error at -1 {{cannot delete expression with pointer-to-'void' type 'void *'}}
+ delete q;
+ // expected-error at -1 {{cannot delete expression of type 'void (*)()'}}
+ delete s;
+ // expected-error at -1 {{cannot delete expression with pointer-to-'void' type 'void *'}}
+ delete t;
+ // expected-error at -1 {{cannot delete expression of type 'T'}}
// FIXME: This is valid, but is rejected due to a non-conforming GNU
// extension allowing deletion of pointers to void.
- delete u; // expected-error {{ambiguous}}
+ delete u;
+ // expected-error at -1 {{ambiguous conversion of delete expression of type 'U' to a pointer}}
+ // expected-note@#dr599-U {{conversion to pointer type 'int *'}}
+ // expected-note@#dr599-U {{conversion to pointer type 'void *'}}
delete v;
}
}
More information about the cfe-commits
mailing list