[cfe-commits] r54335 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Basic/Diagnostic.cpp test/Analysis/NSString.m test/Analysis/dead-stores.c test/Analysis/null-deref-ps.c test/Sema/format-strings.c
Daniel Dunbar
daniel at zuster.org
Mon Aug 4 17:07:51 PDT 2008
Author: ddunbar
Date: Mon Aug 4 19:07:51 2008
New Revision: 54335
URL: http://llvm.org/viewvc/llvm-project?rev=54335&view=rev
Log:
Add EXTWARN Diagnostic class.
- Like EXTENSION but always generates a warning (even without
-pedantic).
- Updated ptr -> int, int -> ptr, and incompatible cast warnings to
be EXTWARN.
- Other EXTENSION level diagnostics should be audited for upgrade.
- Updated several test cases to fix code which produced unanticipated
warnings.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/test/Analysis/NSString.m
cfe/trunk/test/Analysis/dead-stores.c
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Sema/format-strings.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=54335&r1=54334&r2=54335&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Aug 4 19:07:51 2008
@@ -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 @@
// 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,
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=54335&r1=54334&r2=54335&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Mon Aug 4 19:07:51 2008
@@ -29,7 +29,8 @@
NOTE = 0x01,
WARNING = 0x02,
EXTENSION = 0x03,
- ERROR = 0x04,
+ EXTWARN = 0x04,
+ ERROR = 0x05,
class_mask = 0x07
};
@@ -182,6 +183,8 @@
DiagClass = WARNING;
else
return Ignored;
+ } else if (DiagClass == EXTWARN) {
+ DiagClass = ErrorOnExtensions ? ERROR : WARNING;
}
// If warnings are globally mapped to ignore or error, do it.
Modified: cfe/trunk/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=54335&r1=54334&r2=54335&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NSString.m (original)
+++ cfe/trunk/test/Analysis/NSString.m Mon Aug 4 19:07:51 2008
@@ -99,15 +99,16 @@
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}}
Modified: cfe/trunk/test/Analysis/dead-stores.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.c?rev=54335&r1=54334&r2=54335&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dead-stores.c (original)
+++ cfe/trunk/test/Analysis/dead-stores.c Mon Aug 4 19:07:51 2008
@@ -54,6 +54,7 @@
}
int f8(int *p) {
+ extern int *baz();
if (p = baz()) // expected-warning{{Although the value}}
return 1;
return 0;
Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=54335&r1=54334&r2=54335&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Mon Aug 4 19:07:51 2008
@@ -41,7 +41,7 @@
int f4(int *p) {
- uintptr_t x = p;
+ uintptr_t x = (uintptr_t) p;
if (x)
return 1;
Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=54335&r1=54334&r2=54335&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Mon Aug 4 19:07:51 2008
@@ -61,8 +61,8 @@
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 @@
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
+}
More information about the cfe-commits
mailing list