diff options
-rw-r--r-- | include/clang/Basic/DiagnosticKinds.def | 11 | ||||
-rw-r--r-- | lib/Basic/Diagnostic.cpp | 5 | ||||
-rw-r--r-- | test/Analysis/NSString.m | 9 | ||||
-rw-r--r-- | test/Analysis/dead-stores.c | 1 | ||||
-rw-r--r-- | test/Analysis/null-deref-ps.c | 2 | ||||
-rw-r--r-- | test/Sema/format-strings.c | 6 |
6 files changed, 21 insertions, 13 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def index e5bbdd372a..7afe5723a4 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/include/clang/Basic/DiagnosticKinds.def @@ -17,6 +17,9 @@ // NOTE - Informational message. // WARNING - Warning. // EXTENSION - Notification that an extension to the language is being used. +// EXTWARN - Warning for behaviour that is supported as an extension. This +// differs from EXTENSION in that the warning is always emitted +// by default. // ERROR - Error, compilation will stop after parsing completes. //===----------------------------------------------------------------------===// @@ -943,15 +946,15 @@ DIAG(err_invalid_non_static_member_use, ERROR, // assignment related diagnostics (also for argument passing, returning, etc). DIAG(err_typecheck_convert_incompatible, ERROR, "incompatible type %2 '%1', expected '%0'") -DIAG(ext_typecheck_convert_pointer_int, EXTENSION, +DIAG(ext_typecheck_convert_pointer_int, EXTWARN, "incompatible pointer to integer conversion %2 '%1', expected '%0'") -DIAG(ext_typecheck_convert_int_pointer, EXTENSION, +DIAG(ext_typecheck_convert_int_pointer, EXTWARN, "incompatible integer to pointer conversion %2 '%1', expected '%0'") DIAG(ext_typecheck_convert_pointer_void_func, EXTENSION, "%2 '%1' converts between void* and function pointer, expected '%0'") -DIAG(ext_typecheck_convert_incompatible_pointer, EXTENSION, +DIAG(ext_typecheck_convert_incompatible_pointer, EXTWARN, "incompatible pointer types %2 '%1', expected '%0'") -DIAG(ext_typecheck_convert_discards_qualifiers, EXTENSION, +DIAG(ext_typecheck_convert_discards_qualifiers, EXTWARN, "%2 '%1' discards qualifiers, expected '%0'") DIAG(err_typecheck_array_not_modifiable_lvalue, ERROR, diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index fbf118f275..35d665d1a5 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -29,7 +29,8 @@ enum { NOTE = 0x01, WARNING = 0x02, EXTENSION = 0x03, - ERROR = 0x04, + EXTWARN = 0x04, + ERROR = 0x05, class_mask = 0x07 }; @@ -182,6 +183,8 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const { DiagClass = WARNING; else return Ignored; + } else if (DiagClass == EXTWARN) { + DiagClass = ErrorOnExtensions ? ERROR : WARNING; } // If warnings are globally mapped to ignore or error, do it. diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m index a85a87aace..a56c5b8585 100644 --- a/test/Analysis/NSString.m +++ b/test/Analysis/NSString.m @@ -99,15 +99,16 @@ NSComparisonResult f5(NSString* s, NSStringCompareOptions op, NSRange R) { return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil.}} } -NSComparisonResult f6(NSString* s) { +NSArray *f6(NSString* s) { return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil.}} } NSString* f7(NSString* s1, NSString* s2, NSString* s3) { - NSString* s4 = CFStringCreateWithFormat(kCFAllocatorDefault, 0, - L"%@ %@ (%@)", - s1, s2, s3); + NSString* s4 = (NSString*) + CFStringCreateWithFormat(kCFAllocatorDefault, 0, + (CFStringRef) __builtin___CFStringMakeConstantString("%@ %@ (%@)"), + s1, s2, s3); CFRetain(s4); return s4; // expected-warning{{leak}} diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index 0ca289231b..6811ece1fe 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -54,6 +54,7 @@ int f7(int *p) { } int f8(int *p) { + extern int *baz(); if (p = baz()) // expected-warning{{Although the value}} return 1; return 0; diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 57e4718fe6..6da44d0c73 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -41,7 +41,7 @@ int f3_b(char* x) { int f4(int *p) { - uintptr_t x = p; + uintptr_t x = (uintptr_t) p; if (x) return 1; diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index c1e690a3b8..2d6e719e3a 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -61,8 +61,8 @@ void check_wide_string(char* b, ...) va_list ap; va_start(ap,b); - printf(L"foo %d",2); // expected-warning {{should not be a wide string}} - vasprintf(&b,L"bar %d",ap); // expected-warning {{should not be a wide string}} + printf(L"foo %d",2); // expected-warning {{incompatible pointer types}}, expected-warning {{should not be a wide string}} + vasprintf(&b,L"bar %d",ap); // expected-warning {{incompatible pointer types}}, expected-warning {{should not be a wide string}} } void check_asterisk_precision_width(int x) { @@ -71,4 +71,4 @@ void check_asterisk_precision_width(int x) { printf("%*d",12,x); // no-warning printf("%*d","foo",x); // expected-warning {{field width should have type 'int', but argument has type 'char *'}} printf("%.*d","foo",x); // expected-warning {{field precision should have type 'int', but argument has type 'char *'}} -}
\ No newline at end of file +} |