From 5e664911984c22c8aae06e0a40ff62196508f620 Mon Sep 17 00:00:00 2001 From: MacDue Date: Wed, 23 Jul 2025 23:33:53 +0100 Subject: [PATCH] [clang] Fix crash when diagnosing unsupported attributes In #141305, the attribute argument was (unintentionally) removed from the diagnostic emission. Fixes #150237 --- clang/lib/Sema/SemaDeclAttr.cpp | 3 ++- clang/test/Sema/unsupported-arm-streaming.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/unsupported-arm-streaming.cpp diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 9a2950cf1648e..5334b26daac40 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2034,7 +2034,8 @@ bool Sema::CheckAttrTarget(const ParsedAttr &AL) { // Check whether the attribute is valid on the current target. if (!AL.existsInTarget(Context.getTargetInfo())) { if (AL.isRegularKeywordAttribute()) - Diag(AL.getLoc(), diag::err_keyword_not_supported_on_target); + Diag(AL.getLoc(), diag::err_keyword_not_supported_on_target) + << AL << AL.getRange(); else DiagnoseUnknownAttribute(AL); AL.setInvalid(); diff --git a/clang/test/Sema/unsupported-arm-streaming.cpp b/clang/test/Sema/unsupported-arm-streaming.cpp new file mode 100644 index 0000000000000..8693dd6875d50 --- /dev/null +++ b/clang/test/Sema/unsupported-arm-streaming.cpp @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s + +void arm_streaming(void) __arm_streaming {} // expected-error {{'__arm_streaming' is not supported on this target}}