Allow -Wformat to be enabled without -Wformat-security. GCC gates

-Wformat-security on -Wformat, not vice-versa.

Fixes PR8486. Patch by Oleg Slezberg.

llvm-svn: 126096
This commit is contained in:
Chandler Carruth 2011-02-21 00:07:51 +00:00
parent 15fe190027
commit 468b5cbd40
2 changed files with 14 additions and 2 deletions

View File

@ -198,9 +198,11 @@ def Unused : DiagGroup<"unused",
DiagCategory<"Unused Entity Issue">;
// Format settings.
def Format : DiagGroup<"format", [FormatExtraArgs, FormatZeroLength, NonNull]>,
def FormatSecurity : DiagGroup<"format-security">;
def Format : DiagGroup<"format",
[FormatExtraArgs, FormatZeroLength, NonNull,
FormatSecurity]>,
DiagCategory<"Format String Issue">;
def FormatSecurity : DiagGroup<"format-security", [Format]>;
def FormatNonLiteral : DiagGroup<"format-nonliteral", [FormatSecurity]>;
def FormatY2K : DiagGroup<"format-y2k", [Format]>;
def Format2 : DiagGroup<"format=2",

View File

@ -340,3 +340,13 @@ void posix_extensions() {
printf("%'f\n", (float) 1.0); // no-warning
printf("%'p\n", (void*) 0); // expected-warning{{results in undefined behavior with 'p' conversion specifier}}
}
// PR8486
//
// Test what happens when -Wformat is on, but -Wformat-security is off.
#pragma GCC diagnostic warning "-Wformat"
#pragma GCC diagnostic ignored "-Wformat-security"
void pr8486() {
printf("%s", 1); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
}