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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54335 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index e5bbdd3..7afe572 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 @@
 // 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 fbf118f..35d665d 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -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.
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index a85a87a..a56c5b8 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -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}}
diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c
index 0ca2892..6811ece 100644
--- a/test/Analysis/dead-stores.c
+++ b/test/Analysis/dead-stores.c
@@ -54,6 +54,7 @@
 }
 
 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 57e4718..6da44d0 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -41,7 +41,7 @@
 
 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 c1e690a..2d6e719 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -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
+}