[clang] [clang] Add -Wused-but-marked-unused to -Wattributes (PR #179790)
John Paul Jepko via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 5 23:43:38 PST 2026
https://github.com/jpjepko updated https://github.com/llvm/llvm-project/pull/179790
>From a402efdefed48cbe72282969de52d44946c26b7d Mon Sep 17 00:00:00 2001
From: John Jepko <john.jepko at ericsson.com>
Date: Wed, 4 Feb 2026 17:41:24 +0100
Subject: [PATCH 1/3] add Wused-but-marked-unused to Wattributes
---
clang/include/clang/Basic/DiagnosticGroups.td | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 488f3a94c4fb6..cf2bc00cc2e21 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1010,8 +1010,9 @@ def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;
def UnknownAttributes : DiagGroup<"unknown-attributes">;
def IgnoredAttributes : DiagGroup<"ignored-attributes",
[DllexportExplicitInstantiation]>;
-def Attributes : DiagGroup<"attributes", [UnknownAttributes,
- IgnoredAttributes]>;
+def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">;
+def Attributes : DiagGroup<"attributes", [UnknownAttributes, IgnoredAttributes,
+ UsedButMarkedUnused]>;
def UnknownSanitizers : DiagGroup<"unknown-sanitizers">;
def UnnamedTypeTemplateArgs : DiagGroup<"unnamed-type-template-args",
[CXX98CompatUnnamedTypeTemplateArgs]>;
@@ -1047,7 +1048,6 @@ def UnusedButSetVariable : DiagGroup<"unused-but-set-variable">;
def UnusedLocalTypedef : DiagGroup<"unused-local-typedef">;
def UnusedPropertyIvar : DiagGroup<"unused-property-ivar">;
def UnusedGetterReturnValue : DiagGroup<"unused-getter-return-value">;
-def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">;
def UsedSearchPath : DiagGroup<"search-path-usage">;
def UserDefinedLiterals : DiagGroup<"user-defined-literals">;
def UserDefinedWarnings : DiagGroup<"user-defined-warnings">;
>From 72cb70bf7c99cafd6ed4e4888d0f86f61a9a5cb4 Mon Sep 17 00:00:00 2001
From: John Jepko <john.jepko at ericsson.com>
Date: Wed, 4 Feb 2026 23:39:10 +0100
Subject: [PATCH 2/3] test -Wattributes enables -Wused-but-marked-unsed
---
clang/test/Sema/attr-unused.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/test/Sema/attr-unused.c b/clang/test/Sema/attr-unused.c
index 49b90b5f50eac..8d3519b39e1d9 100644
--- a/clang/test/Sema/attr-unused.c
+++ b/clang/test/Sema/attr-unused.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -Wno-strict-prototypes -fsyntax-only %s
+// RUN: %clang_cc1 -verify -Wunused -Wattributes -Wunused-parameter -Wunused -Wno-strict-prototypes -fsyntax-only %s
static void (*fp0)(void) __attribute__((unused));
>From 0bea8b0dcbd2df4d99ae1c1a1d02f806f3636ee1 Mon Sep 17 00:00:00 2001
From: John Jepko <john.jepko at ericsson.com>
Date: Fri, 6 Feb 2026 08:34:56 +0100
Subject: [PATCH 3/3] remove duplicate -Wunused in RUN directives
---
clang/test/Sema/attr-unused.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/Sema/attr-unused.c b/clang/test/Sema/attr-unused.c
index 8d3519b39e1d9..d745fb3a8a1d5 100644
--- a/clang/test/Sema/attr-unused.c
+++ b/clang/test/Sema/attr-unused.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -Wno-strict-prototypes -fsyntax-only %s
-// RUN: %clang_cc1 -verify -Wunused -Wattributes -Wunused-parameter -Wunused -Wno-strict-prototypes -fsyntax-only %s
+// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wno-strict-prototypes -fsyntax-only %s
+// RUN: %clang_cc1 -verify -Wunused -Wattributes -Wunused-parameter -Wno-strict-prototypes -fsyntax-only %s
static void (*fp0)(void) __attribute__((unused));
More information about the cfe-commits
mailing list