65 lines
2.8 KiB
Diff
65 lines
2.8 KiB
Diff
From d8c293d66499cb2b94eb8a8be1e6fd9fd87847be Mon Sep 17 00:00:00 2001
|
|
From: Nikita Popov <npopov@redhat.com>
|
|
Date: Fri, 19 Jan 2024 15:19:58 +0100
|
|
Subject: [PATCH] Fix build with GCC 14 on ARM (#78704)
|
|
|
|
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.
|
|
---
|
|
clang/include/clang/Basic/AttributeCommonInfo.h | 2 +-
|
|
clang/include/clang/Basic/TokenKinds.def | 3 ++-
|
|
clang/utils/TableGen/ClangAttrEmitter.cpp | 2 +-
|
|
3 files changed, 4 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h b/clang/include/clang/Basic/AttributeCommonInfo.h
|
|
index d787e4959bfe..ef2ddf525c98 100644
|
|
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
|
|
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
|
|
@@ -260,7 +260,7 @@ inline bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind) {
|
|
switch (Kind) {
|
|
default:
|
|
return false;
|
|
-#define KEYWORD_ATTRIBUTE(NAME, HASARG) \
|
|
+#define KEYWORD_ATTRIBUTE(NAME, HASARG, ...) \
|
|
case tok::kw_##NAME: \
|
|
return HASARG;
|
|
#include "clang/Basic/RegularKeywordAttrInfo.inc"
|
|
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
|
|
index d15e4970b7d8..c10e2adfbe6e 100644
|
|
--- a/clang/include/clang/Basic/TokenKinds.def
|
|
+++ b/clang/include/clang/Basic/TokenKinds.def
|
|
@@ -760,8 +760,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, HASARG, EMPTY) KEYWORD(EMPTY ## X, KEYALL)
|
|
#endif
|
|
#include "clang/Basic/RegularKeywordAttrInfo.inc"
|
|
|
|
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
|
|
index a1827f8ce0ea..3888e6c08ab0 100644
|
|
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
|
|
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
|
|
@@ -3589,7 +3589,7 @@ void EmitClangRegularKeywordAttributeInfo(RecordKeeper &Records,
|
|
|
|
OS << "KEYWORD_ATTRIBUTE("
|
|
<< S.getSpellingRecord().getValueAsString("Name") << ", "
|
|
- << (HasArgs ? "true" : "false") << ")\n";
|
|
+ << (HasArgs ? "true" : "false") << ", )\n";
|
|
}
|
|
OS << "#undef KEYWORD_ATTRIBUTE\n";
|
|
}
|
|
--
|
|
2.47.0
|
|
|