| Issue |
175414
|
| Summary |
Option to make command-line -Werror=<group> take precedence over source-level #pragma clang diagnostic ignored
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
pengyuxiao
|
Clang allows source code to suppress a warning group using #pragma clang diagnostic ignored "-W<group>" even when the build system explicitly promotes that group to an error via -Werror=<group>.
In large codebases, this makes it difficult to enforce project-wide diagnostic policies (e.g., warning-as-error for certain groups), because local pragmas can silently disable those diagnostics.
Reproducer:
// clang_bypass.c
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
struct S1 { int a; };
struct S2 { int b; };
static struct S2 g_var;
void test(void) {
struct S1 *ptr = &g_var;
(void)ptr;
}
Environment:clang 22.0.0
Command: clang -std=c11 -Wall -Wextra -Werror=incompatible-pointer-types -c clang_bypass.c
Actual result:Compilation succeeds with exit code 0 and no diagnostics.
Expected result :Provide an opt-in mechanism so that command-line -Werror=<group> cannot be disabled by source-level pragmas, or alternatively emit a diagnostic/note indicating that a warning promoted to error was suppressed by a pragma.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs