aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-01-19 15:19:58 +0100
committerMichał Górny <mgorny@gentoo.org>2024-02-15 16:59:52 +0100
commit54ce0e62fce2f1d6393da77a2b1691d88964ee51 (patch)
treea6173ea62e13deb63deed558c612d936efff73ac
parentcompiler-rt: Fix FLOAT16 feature detection (diff)
downloadllvm-project-54ce0e62fce2f1d6393da77a2b1691d88964ee51.tar.gz
llvm-project-54ce0e62fce2f1d6393da77a2b1691d88964ee51.tar.bz2
llvm-project-54ce0e62fce2f1d6393da77a2b1691d88964ee51.zip
[Clang] Fix build with GCC 14 on ARM (#78704)gentoo-17.0.6-r1
GCC 14 defines `__arm_streaming` as a macro expanding to `[[arm::streaming]]`. Due to the nested macro use, this gets expanded prior to concatenation. It doesn't look like C++ has a really clean way to prevent macro expansion. The best I have found is to use `EMPTY ## X` where `EMPTY` is an empty macro argument, so this is the hack I'm implementing here. Fixes https://github.com/llvm/llvm-project/issues/78691. Rebased for 17.x by Michał Górny. Gentoo-Component: clang
-rw-r--r--clang/include/clang/Basic/TokenKinds.def3
-rw-r--r--clang/include/clang/Basic/TokenKinds.h2
-rw-r--r--clang/utils/TableGen/ClangAttrEmitter.cpp2
3 files changed, 4 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index ef0dad0f2dcd..3add13c079f3 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -752,8 +752,9 @@ KEYWORD(__builtin_available , KEYALL)
KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL)
// Keywords defined by Attr.td.
+// The "EMPTY ## X" is used to prevent early macro-expansion of the keyword.
#ifndef KEYWORD_ATTRIBUTE
-#define KEYWORD_ATTRIBUTE(X) KEYWORD(X, KEYALL)
+#define KEYWORD_ATTRIBUTE(X, EMPTY) KEYWORD(EMPTY ## X, KEYALL)
#endif
#include "clang/Basic/AttrTokenKinds.inc"
diff --git a/clang/include/clang/Basic/TokenKinds.h b/clang/include/clang/Basic/TokenKinds.h
index e4857405bc7f..ff117bd5afc5 100644
--- a/clang/include/clang/Basic/TokenKinds.h
+++ b/clang/include/clang/Basic/TokenKinds.h
@@ -109,7 +109,7 @@ bool isPragmaAnnotation(TokenKind K);
inline constexpr bool isRegularKeywordAttribute(TokenKind K) {
return (false
-#define KEYWORD_ATTRIBUTE(X) || (K == tok::kw_##X)
+#define KEYWORD_ATTRIBUTE(X, ...) || (K == tok::kw_##X)
#include "clang/Basic/AttrTokenKinds.inc"
);
}
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index b5813c6abc2b..79db17501b64 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3430,7 +3430,7 @@ void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) {
"RegularKeyword attributes with arguments are not "
"yet supported");
OS << "KEYWORD_ATTRIBUTE("
- << S.getSpellingRecord().getValueAsString("Name") << ")\n";
+ << S.getSpellingRecord().getValueAsString("Name") << ", )\n";
}
OS << "#undef KEYWORD_ATTRIBUTE\n";
}