-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Warning as error Array Comparisons from C++26 #118872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
30eb50c
f91c1a3
c3b15ca
a36a3c4
14624e0
62b4192
5280439
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10274,6 +10274,11 @@ def warn_array_comparison : Warning< | |||||||
| "to compare array addresses, use unary '+' to decay operands to pointers">, | ||||||||
| InGroup<DiagGroup<"array-compare">>; | ||||||||
|
|
||||||||
| def warn_array_comparison_cxx26 : Warning< | ||||||||
| "comparison between two arrays compare their addresses not their contents; " | ||||||||
|
||||||||
| def err_access_decl : Error< | |
| "ISO C++11 does not allow access declarations; " | |
| "use using declarations instead">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that we have diagnostics with 'not allowed' and 'ill-formed' in the codebase, I am okay with both, and we can agree on opinion.
What do you think the best option here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it matters a lot. ill formed conveys it's a standard requirement pretty well
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -verify=expected,not-cxx20 | ||
| // RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeprecated -verify %s -verify=expected,cxx20 | ||
| // RUN: %clang_cc1 -std=c++26 -fsyntax-only -Wdeprecated -verify %s -verify=expected,cxx26 | ||
|
|
||
| void f(int (&array1)[2], int (&array2)[2]) { | ||
| if (array1 == array2) { } // not-cxx20-warning {{comparison between two arrays compare their addresses}} cxx20-warning {{comparison between two arrays is deprecated}} | ||
| // cxx26-error@-1 {{comparison between two arrays compare their addresses not their contents}} | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -239,7 +239,7 @@ <h2 id="cxx26">C++2c implementation status</h2> | |||||
| <tr> | ||||||
| <td>Remove Deprecated Array Comparisons from C++26</td> | ||||||
| <td><a href="https://wg21.link/P2865R6">P2865R6</a></td> | ||||||
| <td class="none" align="center">No</td> | ||||||
| <td class="none" align="center">Clang 20</td> | ||||||
|
||||||
| <td class="none" align="center">Clang 20</td> | |
| <td class="unreleased" align="center">Clang 20</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done