Skip to content

Commit d8a1c6d

Browse files
authored
[Clang] update reasoned delete diagnostic kind to use Extension, making it pedantic only (#114713)
Fixes #109311 --- #109311 (comment)
1 parent 68b7ab1 commit d8a1c6d

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ Improvements to Clang's diagnostics
556556
getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
557557
}
558558

559+
- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
560+
559561
Improvements to Clang's time-trace
560562
----------------------------------
561563

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ def warn_cxx98_compat_defaulted_deleted_function : Warning<
976976
"%select{defaulted|deleted}0 function definitions are incompatible with C++98">,
977977
InGroup<CXX98Compat>, DefaultIgnore;
978978

979-
def ext_delete_with_message : ExtWarn<
979+
def ext_delete_with_message : Extension<
980980
"'= delete' with a message is a C++2c extension">, InGroup<CXX26>;
981981
def warn_cxx23_delete_with_message : Warning<
982982
"'= delete' with a message is incompatible with C++ standards before C++2c">,

clang/test/Parser/cxx2c-delete-with-message.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify=expected,pre26 -pedantic %s
1+
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26 %s
2+
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26-pedantic -pedantic %s
23
// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify=expected,compat -Wpre-c++26-compat %s
34
// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s
45

@@ -7,15 +8,15 @@ struct S {
78
void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}}
89
void c() = delete(); // expected-error {{expected string literal}}
910
void d() = delete(42); // expected-error {{expected string literal}}
10-
void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
11-
void f() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
12-
13-
S() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
14-
~S() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
15-
S(const S&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
16-
S(S&&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
17-
S& operator=(const S&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
18-
S& operator=(S&&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
11+
void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
12+
void f() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
13+
14+
S() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
15+
~S() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
16+
S(const S&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
17+
S(S&&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
18+
S& operator=(const S&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
19+
S& operator=(S&&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
1920
};
2021

2122
struct T {
@@ -31,8 +32,8 @@ void a() = delete;
3132
void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}}
3233
void c() = delete(); // expected-error {{expected string literal}}
3334
void d() = delete(42); // expected-error {{expected string literal}}
34-
void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
35-
void f() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
35+
void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
36+
void f() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
3637

3738
constexpr const char *getMsg() { return "this is a message"; }
3839
void func() = delete(getMsg()); // expected-error {{expected string literal}}
@@ -49,3 +50,12 @@ struct C {
4950
U f = delete ("hello"); // expected-error {{cannot delete expression of type 'const char[6]'}}
5051
};
5152
}
53+
54+
namespace GH109311 {
55+
void f() = delete
56+
#if __cpp_deleted_function >= 202403L
57+
("reason") // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} \
58+
// compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2}}
59+
#endif
60+
;
61+
}

0 commit comments

Comments
 (0)