https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595
>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun <zijunz...@google.com> Date: Sat, 13 Apr 2024 00:53:38 +0000 Subject: [PATCH 1/2] Carving out -Wformat warning about scoped enums into a subwarning Make it part of -Wformat-pedantic. --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++-- clang/test/Sema/format-strings-scanf.c | 2 +- clang/test/Sema/format-strings-signedness.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 774d2b53a38252..4ba27d62208da4 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning< def warn_format_conversion_argument_type_mismatch : Warning< "format specifies type %0 but the argument has " "%select{type|underlying type}2 %1">, - InGroup<Format>; + InGroup<FormatPedantic>; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup<FormatPedantic>; @@ -9840,7 +9840,7 @@ def warn_format_conversion_argument_type_mismatch_confusion : Warning< def warn_format_argument_needs_cast : Warning< "%select{values of type|enum values with underlying type}2 '%0' should not " "be used as format arguments; add an explicit cast to %1 instead">, - InGroup<Format>; + InGroup<FormatPedantic>; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup<FormatPedantic>, DefaultIgnore; diff --git a/clang/test/Sema/format-strings-scanf.c b/clang/test/Sema/format-strings-scanf.c index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644 --- a/clang/test/Sema/format-strings-scanf.c +++ b/clang/test/Sema/format-strings-scanf.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s // Test that -Wformat=0 works: -// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s +// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 -Wno-format-pedantic %s #include <stdarg.h> typedef __SIZE_TYPE__ size_t; diff --git a/clang/test/Sema/format-strings-signedness.c b/clang/test/Sema/format-strings-signedness.c index d5a8140d9ef8a0..ccd4d72c2d2635 100644 --- a/clang/test/Sema/format-strings-signedness.c +++ b/clang/test/Sema/format-strings-signedness.c @@ -12,8 +12,8 @@ // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat -verify=okay %s // Verify that -Wformat-signedness with -Wno-format are not reported (gcc compat). -// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat-signedness -Wno-format -verify=okay %s -// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wno-format -Wformat-signedness -verify=okay %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat-signedness -Wno-format -verify %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wno-format -Wformat-signedness -verify %s // okay-no-diagnostics int printf(const char *restrict format, ...); @@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) { void test_suppress(int x) { #pragma GCC diagnostic ignored "-Wformat" - printf("%u", x); + printf("%u", x); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'int'}} } >From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001 From: Zijun <zijunz...@google.com> Date: Sat, 13 Apr 2024 00:53:38 +0000 Subject: [PATCH 2/2] Carving out -Wformat warning about scoped enums into a subwarning Make it part of -Wformat-pedantic. Fixes #81647 --- clang/test/Sema/format-strings-signedness.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/Sema/format-strings-signedness.c b/clang/test/Sema/format-strings-signedness.c index ccd4d72c2d2635..a06884cb9fe090 100644 --- a/clang/test/Sema/format-strings-signedness.c +++ b/clang/test/Sema/format-strings-signedness.c @@ -11,7 +11,7 @@ // (gcc compat). // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat -verify=okay %s -// Verify that -Wformat-signedness with -Wno-format are not reported (gcc compat). +// Verify that -Wformat-signedness with -Wno-format are still reported (gcc compat). // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat-signedness -Wno-format -verify %s // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wno-format -Wformat-signedness -verify %s // okay-no-diagnostics @@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) { printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning } -// Verify that we can suppress a -Wformat-signedness warning by ignoring +// Verify that we can not suppress a -Wformat-signedness warning by ignoring // -Wformat (gcc compat). void test_suppress(int x) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits