[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 2 17:19:54 PST 2025


https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/120925

>From bce88b1bb464438828fc177c978ad2b99957530f Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Mon, 23 Dec 2024 02:35:07 +0200
Subject: [PATCH 1/3] [Clang] raise extension warning for unknown namespaced
 attributes

---
 clang/docs/ReleaseNotes.rst                            |  2 ++
 clang/include/clang/Basic/DiagnosticCommonKinds.td     |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp                        |  2 ++
 .../CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp    |  4 ++--
 clang/test/CXX/module/module.interface/p3.cpp          |  2 +-
 clang/test/Lexer/cxx2a-spaceship.cpp                   |  2 +-
 clang/test/OpenMP/openmp_attribute_parsing.cpp         |  2 +-
 clang/test/Parser/c2x-attributes.c                     |  2 +-
 clang/test/Parser/cxx0x-attributes.cpp                 |  2 +-
 clang/test/Sema/patchable-function-entry-attr.cpp      |  2 +-
 clang/test/Sema/unknown-attributes.c                   | 10 ++++++++++
 clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp      |  4 ++--
 12 files changed, 26 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/Sema/unknown-attributes.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..e2cf90aecf3666 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -552,6 +552,8 @@ Attribute Changes in Clang
 - Clang now permits the usage of the placement new operator in ``[[msvc::constexpr]]``
   context outside of the std namespace. (#GH74924)
 
+- Clang now raises warnings for unknown namespaced attributes only in pedantic mode (#GH120875).
+
 Improvements to Clang's diagnostics
 -----------------------------------
 
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index f4a155bb00bb37..85653429aa5332 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -179,6 +179,8 @@ def err_opencl_unknown_type_specifier : Error<
 
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
+def ext_unknown_attribute_ignored : Extension<
+  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">,
   InGroup<IgnoredAttributes>;
 def err_keyword_not_supported_on_target : Error<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bb4d33560b93b8..9b1ffebe0804a5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6548,6 +6548,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
                ? (unsigned)diag::err_keyword_not_supported_on_target
            : AL.isDeclspecAttribute()
                ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
+           : AL.getScopeName()
+               ? (unsigned)diag::ext_unknown_attribute_ignored
                : (unsigned)diag::warn_unknown_attribute_ignored)
         << AL << AL.getRange();
     return;
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
index 192fa126109873..c7e66649fb7b22 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
@@ -12,5 +12,5 @@
 [[using clang:]] extern int n; // ok
 [[using blah: clang::optnone]] extern int n; // expected-error {{attribute with scope specifier cannot follow}} expected-warning {{only applies to functions}}
 
-[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown attribute}}
-[[using unknown_ns: something]] extern int n; // expected-warning {{unknown attribute}}
+[[using clang: unknown_attr]] extern int n;
+[[using unknown_ns: something]] extern int n;
diff --git a/clang/test/CXX/module/module.interface/p3.cpp b/clang/test/CXX/module/module.interface/p3.cpp
index 32819b2dccb11d..3cde92c1a2cf34 100644
--- a/clang/test/CXX/module/module.interface/p3.cpp
+++ b/clang/test/CXX/module/module.interface/p3.cpp
@@ -40,7 +40,7 @@ export { // No diagnostic after P2615R1 DR
   extern "C++" {} // No diagnostic after P2615R1 DR
 }
 export [[]]; // No diagnostic after P2615R1 DR
-export [[example::attr]]; // expected-warning {{unknown attribute 'attr'}}
+export [[example::attr]]; // expected-error {{unknown attribute 'attr'}}
 
 // [...] shall not declare a name with internal linkage
 export static int a; // expected-error {{declaration of 'a' with internal linkage cannot be exported}}
diff --git a/clang/test/Lexer/cxx2a-spaceship.cpp b/clang/test/Lexer/cxx2a-spaceship.cpp
index 2163a0bf190f90..505f2f47c8ffb8 100644
--- a/clang/test/Lexer/cxx2a-spaceship.cpp
+++ b/clang/test/Lexer/cxx2a-spaceship.cpp
@@ -61,7 +61,7 @@ static_assert(__builtin_strcmp(b, "<=>") == 0);
 // CXX20: preprocess8: <=>=
 
 #define ID(x) x
-[[some_vendor::some_attribute( // expected-warning {{unknown attribute}}
+[[some_vendor::some_attribute(
 preprocess1: ID(<)ID(=>),
 preprocess2: ID(<=)ID(>),
 preprocess3: ID(<)ID(=)ID(>),
diff --git a/clang/test/OpenMP/openmp_attribute_parsing.cpp b/clang/test/OpenMP/openmp_attribute_parsing.cpp
index e273702dfadcb3..4a3a885e407a75 100644
--- a/clang/test/OpenMP/openmp_attribute_parsing.cpp
+++ b/clang/test/OpenMP/openmp_attribute_parsing.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++17 -fopenmp -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -Wunknown-attributes -fopenmp -fsyntax-only -verify %s
 
 // This file tests the custom parsing logic for the OpenMP 5.1 attribute
 // syntax. It does not test actual OpenMP directive syntax, just the attribute
diff --git a/clang/test/Parser/c2x-attributes.c b/clang/test/Parser/c2x-attributes.c
index be039e40f98ef1..30653e2e6f67a6 100644
--- a/clang/test/Parser/c2x-attributes.c
+++ b/clang/test/Parser/c2x-attributes.c
@@ -133,7 +133,7 @@ void f11(void) {
 }
 
 [[attr]] void f12(void); // expected-warning {{unknown attribute 'attr' ignored}}
-[[vendor::attr]] void f13(void); // expected-warning {{unknown attribute 'attr' ignored}}
+[[vendor::attr]] void f13(void);
 
 // Ensure that asm statements properly handle double colons.
 void test_asm(void) {
diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp
index fad3010c98b9c2..41e4ac4907ef54 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions %s
+// RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions -Wunknown-attributes %s
 
 // Need std::initializer_list
 namespace std {
diff --git a/clang/test/Sema/patchable-function-entry-attr.cpp b/clang/test/Sema/patchable-function-entry-attr.cpp
index bd4d57a7e30936..8c988b453749e9 100644
--- a/clang/test/Sema/patchable-function-entry-attr.cpp
+++ b/clang/test/Sema/patchable-function-entry-attr.cpp
@@ -8,7 +8,7 @@
 // RUN: %clang_cc1 -triple riscv64 -fsyntax-only -verify=silence %s
 // RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fsyntax-only -verify=silence %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -fsyntax-only -verify=silence %s
-// RUN: %clang_cc1 -triple ppc64le -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple ppc64le -fsyntax-only -verify=silence %s
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fsyntax-only -verify=AIX %s
 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fsyntax-only -verify=AIX %s
 
diff --git a/clang/test/Sema/unknown-attributes.c b/clang/test/Sema/unknown-attributes.c
new file mode 100644
index 00000000000000..26fa0258302a38
--- /dev/null
+++ b/clang/test/Sema/unknown-attributes.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify=pedantic -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify %s
+
+// expected-no-diagnostics
+
+[[unknown::a(b((c)) d(e((f)))), unknown::g(h k)]] // pedantic-warning {{unknown attribute 'a' ignored}} \
+                                                  // pedantic-warning {{unknown attribute 'g' ignored}}
+int main(void) {
+    return 0;
+}
diff --git a/clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp b/clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp
index 822ed752fa9c75..90c814a6a7774a 100644
--- a/clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp
+++ b/clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows -fms-compatibility
+// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-linux-gnu -Wunknown-attributes
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows -fms-compatibility -Wunknown-attributes
 
 [[msvc::no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[msvc::no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}

>From 83eac2ed3b8679da9fc6d65f4f36f91b61666bb7 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Mon, 23 Dec 2024 14:32:04 +0200
Subject: [PATCH 2/3] fix formatting

---
 clang/lib/Sema/SemaDeclAttr.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 9b1ffebe0804a5..520508a2c9dff6 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6548,9 +6548,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
                ? (unsigned)diag::err_keyword_not_supported_on_target
            : AL.isDeclspecAttribute()
                ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
-           : AL.getScopeName()
-               ? (unsigned)diag::ext_unknown_attribute_ignored
-               : (unsigned)diag::warn_unknown_attribute_ignored)
+           : AL.getScopeName() ? (unsigned)diag::ext_unknown_attribute_ignored
+                               : (unsigned)diag::warn_unknown_attribute_ignored)
         << AL << AL.getRange();
     return;
   }

>From 4b1baec265612a5b347c064eee4cb18856a7a457 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Fri, 3 Jan 2025 03:19:23 +0200
Subject: [PATCH 3/3] check attrs in known scopes

---
 .../include/clang/Basic/AttributeCommonInfo.h  |  2 ++
 .../clang/Basic/DiagnosticCommonKinds.td       |  2 --
 clang/lib/Basic/Attributes.cpp                 |  8 +++++++-
 clang/lib/Sema/SemaDeclAttr.cpp                | 18 ++++++++++--------
 .../dcl.attr/dcl.attr.grammar/p2-1z.cpp        |  2 +-
 clang/test/CXX/module/module.interface/p3.cpp  |  2 +-
 clang/test/Parser/cxx0x-attributes.cpp         |  7 +++----
 .../Sema/patchable-function-entry-attr.cpp     |  2 +-
 clang/test/Sema/unknown-attributes.c           | 12 +++++++-----
 9 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h b/clang/include/clang/Basic/AttributeCommonInfo.h
index 11c64547721739..c08e3b2a6a6155 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -241,6 +241,8 @@ class AttributeCommonInfo {
   static Kind getParsedKind(const IdentifierInfo *Name,
                             const IdentifierInfo *Scope, Syntax SyntaxUsed);
 
+  bool isKnownScopeName() const;
+
 private:
   /// Get an index into the attribute spelling list
   /// defined in Attr.td. This index is used by an attribute
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 85653429aa5332..f4a155bb00bb37 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -179,8 +179,6 @@ def err_opencl_unknown_type_specifier : Error<
 
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
-def ext_unknown_attribute_ignored : Extension<
-  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">,
   InGroup<IgnoredAttributes>;
 def err_keyword_not_supported_on_target : Error<
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index fa26cc584b724a..640c3d54fce3ee 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -166,7 +166,8 @@ getScopeFromNormalizedScopeName(StringRef ScopeName) {
       .Case("hlsl", AttributeCommonInfo::Scope::HLSL)
       .Case("msvc", AttributeCommonInfo::Scope::MSVC)
       .Case("omp", AttributeCommonInfo::Scope::OMP)
-      .Case("riscv", AttributeCommonInfo::Scope::RISCV);
+      .Case("riscv", AttributeCommonInfo::Scope::RISCV)
+      .Default(AttributeCommonInfo::Scope::NONE);
 }
 
 unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
@@ -181,3 +182,8 @@ unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
 
 #include "clang/Sema/AttrSpellingListIndex.inc"
 }
+
+bool AttributeCommonInfo::isKnownScopeName() const {
+  return getScopeFromNormalizedScopeName(normalizeAttrScopeName(
+             getScopeName(), getSyntax())) != AttributeCommonInfo::Scope::NONE;
+}
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 520508a2c9dff6..229c1832bea405 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6543,14 +6543,16 @@ 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
-           : AL.getScopeName() ? (unsigned)diag::ext_unknown_attribute_ignored
-                               : (unsigned)diag::warn_unknown_attribute_ignored)
-        << AL << AL.getRange();
+
+    unsigned DiagID = diag::warn_unknown_attribute_ignored;
+    if (AL.isRegularKeywordAttribute())
+      DiagID = diag::err_keyword_not_supported_on_target;
+    else if (AL.isDeclspecAttribute())
+      DiagID = diag::warn_unhandled_ms_attribute_ignored;
+    else if (AL.getScopeName() && !AL.isKnownScopeName())
+      return;
+
+    S.Diag(AL.getLoc(), DiagID) << AL << AL.getRange();
     return;
   }
 
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
index c7e66649fb7b22..b44ffba8f2fc35 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
@@ -12,5 +12,5 @@
 [[using clang:]] extern int n; // ok
 [[using blah: clang::optnone]] extern int n; // expected-error {{attribute with scope specifier cannot follow}} expected-warning {{only applies to functions}}
 
-[[using clang: unknown_attr]] extern int n;
+[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown attribute 'unknown_attr' ignored}}
 [[using unknown_ns: something]] extern int n;
diff --git a/clang/test/CXX/module/module.interface/p3.cpp b/clang/test/CXX/module/module.interface/p3.cpp
index 3cde92c1a2cf34..b7ff925e165991 100644
--- a/clang/test/CXX/module/module.interface/p3.cpp
+++ b/clang/test/CXX/module/module.interface/p3.cpp
@@ -40,7 +40,7 @@ export { // No diagnostic after P2615R1 DR
   extern "C++" {} // No diagnostic after P2615R1 DR
 }
 export [[]]; // No diagnostic after P2615R1 DR
-export [[example::attr]]; // expected-error {{unknown attribute 'attr'}}
+export [[example::attr]];
 
 // [...] shall not declare a name with internal linkage
 export static int a; // expected-error {{declaration of 'a' with internal linkage cannot be exported}}
diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp
index 41e4ac4907ef54..fd4bcc6bfc5078 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -46,15 +46,14 @@ int & [[noreturn]] ref_attr_3 = after_attr; // expected-error {{'noreturn' attri
 int && [[]] rref_attr = 0;
 int array_attr [1] [[]];
 alignas(8) int aligned_attr;
-[[test::valid(for 42 [very] **** '+' symbols went on a trip and had a "good"_time; the end.)]] int garbage_attr; // expected-warning {{unknown attribute 'valid' ignored}}
+[[test::valid(for 42 [very] **** '+' symbols went on a trip and had a "good"_time; the end.)]] int garbage_attr;
 [[,,,static, class, namespace,, inline, constexpr, mutable,, bitand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr; // expected-warning {{unknown attribute 'static' ignored}} \
     // expected-warning {{unknown attribute 'class' ignored}} \
     // expected-warning {{unknown attribute 'namespace' ignored}} \
     // expected-warning {{unknown attribute 'inline' ignored}} \
     // expected-warning {{unknown attribute 'constexpr' ignored}} \
     // expected-warning {{unknown attribute 'mutable' ignored}} \
-    // expected-warning {{unknown attribute 'bitand' ignored}} \
-    // expected-warning {{unknown attribute 'compl' ignored}}
+    // expected-warning {{unknown attribute 'bitand' ignored}}
 [[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}}
 void fn_attr () [[]];
 void noexcept_fn_attr () noexcept [[]];
@@ -269,7 +268,7 @@ template <int... Is> void variadic_nttp() {
   void baz [[clang::no_sanitize(Is...)]] ();          // expected-error {{expected string literal as argument of 'no_sanitize' attribute}}
   void bor [[clang::annotate("A", "V" ...)]] ();      // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
   void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // expected-error {{'annotate' attribute requires parameter 1 to be a constant expression}} expected-note {{subexpression not valid in a constant expression}}
-  void boo [[unknown::foo(Is...)]] ();                // expected-warning {{unknown attribute 'foo' ignored}}
+  void boo [[unknown::foo(Is...)]] ();
   void faz [[clang::annotate("C", (Is + ...))]] ();   // expected-warning {{pack fold expression is a C++17 extension}}
   void far [[clang::annotate("D", Is...)]] ();
   void foz [[clang::annotate("E", 1, 2, 3, Is...)]] ();
diff --git a/clang/test/Sema/patchable-function-entry-attr.cpp b/clang/test/Sema/patchable-function-entry-attr.cpp
index 8c988b453749e9..bd4d57a7e30936 100644
--- a/clang/test/Sema/patchable-function-entry-attr.cpp
+++ b/clang/test/Sema/patchable-function-entry-attr.cpp
@@ -8,7 +8,7 @@
 // RUN: %clang_cc1 -triple riscv64 -fsyntax-only -verify=silence %s
 // RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fsyntax-only -verify=silence %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -fsyntax-only -verify=silence %s
-// RUN: %clang_cc1 -triple ppc64le -fsyntax-only -verify=silence %s
+// RUN: %clang_cc1 -triple ppc64le -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fsyntax-only -verify=AIX %s
 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fsyntax-only -verify=AIX %s
 
diff --git a/clang/test/Sema/unknown-attributes.c b/clang/test/Sema/unknown-attributes.c
index 26fa0258302a38..a232653ac4ac8d 100644
--- a/clang/test/Sema/unknown-attributes.c
+++ b/clang/test/Sema/unknown-attributes.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify=pedantic -pedantic %s
 // RUN: %clang_cc1 -fsyntax-only -std=c23 -verify %s
 
-// expected-no-diagnostics
+[[unknown::a(b((c)) d(e((f)))), unknown::g(h k)]]
+int a(void) {
+    return 0;
+}
 
-[[unknown::a(b((c)) d(e((f)))), unknown::g(h k)]] // pedantic-warning {{unknown attribute 'a' ignored}} \
-                                                  // pedantic-warning {{unknown attribute 'g' ignored}}
-int main(void) {
+[[clang::a(b((c)) d(e((f)))), clang::g(h k)]] // expected-warning {{unknown attribute 'a' ignored}} \
+                                              // expected-warning {{unknown attribute 'g' ignored}}
+int b(void) {
     return 0;
 }



More information about the cfe-commits mailing list