[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
Jonathan Wakely via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 06:16:34 PDT 2024
================
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx11 -pedantic -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx14 -pedantic -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 -pedantic -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -pedantic -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx23 -pedantic -std=c++23 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx26 -pedantic -std=c++26 %s
+
+#define noreturn 1 // cxx11-warning {{keyword is hidden by macro definition}}
----------------
jwakely wrote:
> How would that work? `int noreturn = 1;` is valid code AFAICT.
Yes, for attributes, that's true. For keywords it's not though.
The rule was changed between C++03 and C++11 to include #undef, I don't know why though.
I still don't see any advantage in allowing users to `#undef noreturn`.
https://github.com/llvm/llvm-project/pull/106036
More information about the cfe-commits
mailing list