[PATCH] D157572: [clang] Add `[[clang::library_extension]]` attribute

Nikolas Klauser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 10 10:58:34 PDT 2023


philnik added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5690-5691
+def warn_unknown_ext : Warning<"Unknown extension kind: %0">;
+def warn_cxx11_ext : Warning<"%0 is a C++11 extension">,
+    InGroup<CXX11>;
+def warn_cxx14_ext : Warning<"%0 is a C++14 extension">,
----------------
cjdb wrote:
> We shouldn't need this one, since Clang (almost) doesn't distinguish between C++03 and C++11. To my knowledge, C++03 doesn't even support attributes, so this would be a moot addition.
It does enough to regularly cause headaches (no `>>`, `constexpr`, `alignas`, buggy `enum class`). C++03 has supported GNU attributes forever, and since LLVM 17 also supports C++11 attributes. Also note that this isn't a new warning.


================
Comment at: clang/test/SemaCXX/attr-library-extension.cpp:9-13
+#ifdef GNUAttr
+#define EXTENSION(name) __attribute__((library_extension(name)))
+#else
+#define EXTENSION(name) [[clang::library_extension(name)]]
+#endif
----------------
cjdb wrote:
> I don't think we need to test for both of these: using `[[clang::library_extension]]` directly should suffice.
I've been asked to test both before, and IMO it's a good idea, since there are attributes which only have one of the spellings.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157572/new/

https://reviews.llvm.org/D157572



More information about the cfe-commits mailing list