[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK closed https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/AaronBallman approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 1/7] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 2/7] 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 1/6] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 2/6] 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/AaronBallman commented: Please be sure to add a release note in clang/docs/ReleaseNotes.rst. The code changes themselves LGTM, but there are some issues with the tests. https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wformat %s -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-pedantic %s AaronBallman wrote: We're missing a comparison between `-Wformat` and `-Wformat-pedantic` in terms of handling scoped enumerations. We should have a pair of RUN lines to show that this diagnostic is in pedantic only. One thing that helps with testing this is to use something like `-verify=expected,pedantic` and `// pedantic-warning {{msg}}`: https://clang.llvm.org/docs/InternalsManual.html#verifying-diagnostics https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 1/5] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 2/5] 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 1/4] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 2/4] 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wformat %s -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat-pedantic %s 2>&1 | FileCheck %s pirama-arumuga-nainar wrote: With the RUN: line including `-Wformat-pedantic`, do we need the rest of the changes (adding `expected-no-diagnostics` and the removal of `expected-warning`s)? https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
pirama-arumuga-nainar wrote: > Please mention that this fixes #81647 in the patch summary so that the issue > is automatically closed. > > You should also add a release note so that users know about the change (and > link to the issue being closed). This is also pending. The rest of the changes LGTM. https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 1/4] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 2/4] 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 1/3] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH 2/3] 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -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). AaronBallman wrote: Agreed, that seems like an outstanding issue with the PR and should be addressed. Only the scoped enumeration behavior should change. https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -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). karka228 wrote: That discussion is only about -Wformat scoped enums warnings, but this patch currently move all the -Wformat warnings regarding type mismatch into a subwarning, that a lot more warnings than only scoped enums. Is that intended? https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK edited https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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 Date: Sat, 13 Apr 2024 00:53:38 + 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
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/88595 >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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'}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/AaronBallman commented: Please mention that this fixes #81647 in the patch summary so that the issue is automatically closed. You should also add a release note so that users know about the change (and link to the issue being closed). https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -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). AaronBallman wrote: Yes, this is intentional, see the discussion at: https://github.com/llvm/llvm-project/issues/81647#issuecomment-2030070508 https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) { void test_suppress(int x) karka228 wrote: Same as above about gcc compatibility. The comment need at least to be updated. https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
@@ -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). karka228 wrote: The -Wformat-signedness warning was implemented to work the same way as the same warning do in gcc. This patch seems to remove that gcc compatibility. With this patch `-Wformat-signedness` is now controlled by `-Wformat-pedantic` instead of `-Wformat` (as in gcc). I don't know how important it is for clang to be gcc compatible in this way (@AaronBallman what do you think?). At least this comment need to be updated as it no longer match the test below. https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (ZijunZhaoCCK) Changes Make it part of -Wformat-pedantic. --- Full diff: https://github.com/llvm/llvm-project/pull/88595.diff 3 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2-2) - (modified) clang/test/Sema/format-strings-scanf.c (+1-1) - (modified) clang/test/Sema/format-strings-signedness.c (+3-3) ``diff 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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'}} } `` https://github.com/llvm/llvm-project/pull/88595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)
https://github.com/ZijunZhaoCCK created https://github.com/llvm/llvm-project/pull/88595 Make it part of -Wformat-pedantic. >From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001 From: Zijun Date: Sat, 13 Apr 2024 00:53:38 + Subject: [PATCH] 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; + InGroup; def warn_format_conversion_argument_type_mismatch_pedantic : Extension< warn_format_conversion_argument_type_mismatch.Summary>, InGroup; @@ -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; + InGroup; def warn_format_argument_needs_cast_pedantic : Warning< warn_format_argument_needs_cast.Summary>, InGroup, 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 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'}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits