Skip to content

Commit d54dfdd

Browse files
authored
[Clang] 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 #78691.
1 parent 5a7f9a5 commit d54dfdd

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ inline bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind) {
260260
switch (Kind) {
261261
default:
262262
return false;
263-
#define KEYWORD_ATTRIBUTE(NAME, HASARG) \
263+
#define KEYWORD_ATTRIBUTE(NAME, HASARG, ...) \
264264
case tok::kw_##NAME: \
265265
return HASARG;
266266
#include "clang/Basic/RegularKeywordAttrInfo.inc"

clang/include/clang/Basic/TokenKinds.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,9 @@ KEYWORD(__builtin_available , KEYALL)
760760
KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL)
761761

762762
// Keywords defined by Attr.td.
763+
// The "EMPTY ## X" is used to prevent early macro-expansion of the keyword.
763764
#ifndef KEYWORD_ATTRIBUTE
764-
#define KEYWORD_ATTRIBUTE(X, ...) KEYWORD(X, KEYALL)
765+
#define KEYWORD_ATTRIBUTE(X, HASARG, EMPTY) KEYWORD(EMPTY ## X, KEYALL)
765766
#endif
766767
#include "clang/Basic/RegularKeywordAttrInfo.inc"
767768

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3589,7 +3589,7 @@ void EmitClangRegularKeywordAttributeInfo(RecordKeeper &Records,
35893589

35903590
OS << "KEYWORD_ATTRIBUTE("
35913591
<< S.getSpellingRecord().getValueAsString("Name") << ", "
3592-
<< (HasArgs ? "true" : "false") << ")\n";
3592+
<< (HasArgs ? "true" : "false") << ", )\n";
35933593
}
35943594
OS << "#undef KEYWORD_ATTRIBUTE\n";
35953595
}

0 commit comments

Comments
 (0)