[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 4 07:13:01 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}}
----------------
zygoloid wrote:
It looks like we're producing an `Extension` diagnostic here. That means we'll reject under `-pedantic-errors`, which doesn't seem correct, given that I think this entire source file is valid C++ -- I think the "that includes a standard library header" in [macro.names] is intended to cover both /1 and /2, so source files that *don't* include standard library headers are allowed to define these names as macros. (In general, the library wording doesn't get to add core language "shall not" rules, so it wouldn't make any sense for a rule globally disallowing defines of keywords to be there.)
Maybe this diagnostic should be a normal warning not an extension?
https://github.com/llvm/llvm-project/pull/106036
More information about the cfe-commits
mailing list