[clang] c049732 - [clang] Fix crash when diagnosing unsupported attributes (#150333)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 01:42:09 PDT 2025
Author: Benjamin Maxwell
Date: 2025-07-24T09:42:05+01:00
New Revision: c049732d7f946492ec3f6f5e7c3b845b7133fca8
URL: https://github.com/llvm/llvm-project/commit/c049732d7f946492ec3f6f5e7c3b845b7133fca8
DIFF: https://github.com/llvm/llvm-project/commit/c049732d7f946492ec3f6f5e7c3b845b7133fca8.diff
LOG: [clang] Fix crash when diagnosing unsupported attributes (#150333)
In #141305, the attribute argument was (unintentionally) removed from
the diagnostic emission.
Fixes #150237
Added:
clang/test/Sema/unsupported-arm-streaming.cpp
Modified:
clang/lib/Sema/SemaDeclAttr.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 59f89b192ba68..a4e8de49a4229 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2041,7 +2041,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}}
More information about the cfe-commits
mailing list