[clang] [Clang] diagnose unknown attribute namespaces (PR #138519)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 5 09:34:26 PDT 2025


================
@@ -6861,13 +6861,19 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
   // though they were unknown attributes.
   if (AL.getKind() == ParsedAttr::UnknownAttribute ||
       !AL.existsInTarget(S.Context.getTargetInfo())) {
-    S.Diag(AL.getLoc(),
-           AL.isRegularKeywordAttribute()
-               ? (unsigned)diag::err_keyword_not_supported_on_target
-           : AL.isDeclspecAttribute()
-               ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
-               : (unsigned)diag::warn_unknown_attribute_ignored)
-        << AL << AL.getRange();
+    auto D = S.Diag(AL.getLoc(),
+                    AL.isRegularKeywordAttribute()
+                        ? (unsigned)diag::err_keyword_not_supported_on_target
+                    : AL.isDeclspecAttribute()
+                        ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
+                        : (unsigned)diag::warn_unknown_attribute_ignored);
----------------
AaronBallman wrote:

```suggestion
                        ? diag::err_keyword_not_supported_on_target
                    : AL.isDeclspecAttribute()
                        ? diag::warn_unhandled_ms_attribute_ignored
                        : diag::warn_unknown_attribute_ignored);
```
We can get rid of the casts, can't we?

https://github.com/llvm/llvm-project/pull/138519


More information about the cfe-commits mailing list