[cfe-commits] r65647 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/Sema/SemaType.cpp test/Parser/MicrosoftExtensions.c test/Parser/objc-forcollection-neg-2.m test/Parser/traditional_arg_scope.c test/Parser/typeof.c test/Sema/address_spaces.c test/Sema/block-literal.c test/Sema/implicit-int.c test/Sema/invalid-decl.c test/Sema/invalid-struct-init.c

Chris Lattner sabre at nondot.org
Fri Feb 27 10:53:28 PST 2009


Author: lattner
Date: Fri Feb 27 12:53:28 2009
New Revision: 65647

URL: http://llvm.org/viewvc/llvm-project?rev=65647&view=rev
Log:
upgrade various 'implicit int' warnings from an ext-warn to warning when not
in C89 mode.  This makes it enabled by default instead of only enabled with
-pedantic.  Clang defaults to c99 mode, so people will see this more often
than with GCC, but they can always use -std=c89 if they really want c89.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Parser/MicrosoftExtensions.c
    cfe/trunk/test/Parser/objc-forcollection-neg-2.m
    cfe/trunk/test/Parser/traditional_arg_scope.c
    cfe/trunk/test/Parser/typeof.c
    cfe/trunk/test/Sema/address_spaces.c
    cfe/trunk/test/Sema/block-literal.c
    cfe/trunk/test/Sema/implicit-int.c
    cfe/trunk/test/Sema/invalid-decl.c
    cfe/trunk/test/Sema/invalid-struct-init.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Fri Feb 27 12:53:28 2009
@@ -1413,12 +1413,14 @@
 // Type
 DIAG(ext_invalid_sign_spec, EXTENSION,
      "'%0' cannot be signed or unsigned")
-DIAG(ext_missing_declspec, EXTENSION,
+DIAG(warn_missing_declspec, WARNING,
      "declaration specifier missing, defaulting to 'int'")
-DIAG(ext_missing_type_specifier, EXTENSION,
+DIAG(warn_missing_type_specifier, WARNING,
      "type specifier missing, defaults to 'int'")
 DIAG(err_missing_type_specifier, ERROR,
      "C++ requires a type specifier for all declarations")
+DIAG(err_missing_param_declspec, ERROR,
+     "parameter requires a declaration specifier")
 DIAG(warn_objc_array_of_interfaces, WARNING,
      "array of interface %0 should probably be an array of pointers")
 DIAG(ext_c99_array_usage, EXTENSION,

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Feb 27 12:53:28 2009
@@ -74,10 +74,10 @@
     // parser already though by it pretending to have seen an 'int' in this
     // case.
     if (getLangOptions().ImplicitInt) {
-      if ((DS.getParsedSpecifiers() & (DeclSpec::PQ_StorageClassSpecifier |
-                                       DeclSpec::PQ_TypeSpecifier |
-                                       DeclSpec::PQ_TypeQualifier)) == 0)
-        Diag(DS.getSourceRange().getBegin(), diag::ext_missing_declspec);
+      // In C89 mode, we only warn if there is a completely missing declspec
+      // when one is not allowed.
+      if (DS.isEmpty())
+        Diag(DS.getSourceRange().getBegin(), diag::warn_missing_declspec);
     } else if (!DS.hasTypeSpecifier()) {
       // C99 and C++ require a type specifier.  For example, C99 6.7.2p2 says:
       // "At least one type specifier shall be given in the declaration
@@ -86,7 +86,7 @@
       // FIXME: Does Microsoft really have the implicit int extension in C++?
       unsigned DK = getLangOptions().CPlusPlus && !getLangOptions().Microsoft?
           diag::err_missing_type_specifier
-        : diag::ext_missing_type_specifier;
+        : diag::warn_missing_type_specifier;
       Diag(DS.getSourceRange().getBegin(), DK);
     }
       

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.c Fri Feb 27 12:53:28 2009
@@ -11,7 +11,7 @@
 {
     return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
 }
-__forceinline InterlockedBitTestAndSet (long *Base, long Bit)
+__forceinline InterlockedBitTestAndSet (long *Base, long Bit)  // expected-warning {{type specifier missing, defaults to 'int'}}
 {
     __asm {
            mov eax, Bit

Modified: cfe/trunk/test/Parser/objc-forcollection-neg-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-forcollection-neg-2.m?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Parser/objc-forcollection-neg-2.m (original)
+++ cfe/trunk/test/Parser/objc-forcollection-neg-2.m Fri Feb 27 12:53:28 2009
@@ -24,7 +24,7 @@
 
 @implementation MyList (BasicTest)
 - (void)compilerTestAgainst {
-    static i;
+    static i;// expected-warning {{type specifier missing, defaults to 'int'}}
         for (id el, elem in self)  // expected-error {{only one element declaration is allowed}}
            ++i;
         for (id el in self) 

Modified: cfe/trunk/test/Parser/traditional_arg_scope.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/traditional_arg_scope.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Parser/traditional_arg_scope.c (original)
+++ cfe/trunk/test/Parser/traditional_arg_scope.c Fri Feb 27 12:53:28 2009
@@ -1,7 +1,7 @@
 // RUN: clang -fsyntax-only %s -verify
 
-x(a) int a; {return a;}
-y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
+int x(a) int a; {return a;}
+int y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
 
 // PR2332
-a(a)int a;{a=10;return a;}
+int a(a)int a;{a=10;return a;}

Modified: cfe/trunk/test/Parser/typeof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/typeof.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Parser/typeof.c (original)
+++ cfe/trunk/test/Parser/typeof.c Fri Feb 27 12:53:28 2009
@@ -11,7 +11,7 @@
   typeof(TInt) anInt; 
   short TInt eee; // expected-error{{parse error}}
   void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{parse error}}
-  typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-note {{to match this '('}}
+  typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-note {{to match this '('}}  expected-warning {{type specifier missing, defaults to 'int'}}
   typeof(const int) aci; 
   const typeof (*pi) aConstInt; 
   int xx;

Modified: cfe/trunk/test/Sema/address_spaces.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Sema/address_spaces.c (original)
+++ cfe/trunk/test/Sema/address_spaces.c Fri Feb 27 12:53:28 2009
@@ -5,7 +5,7 @@
 #define _AS3 __attribute__((address_space(3)))
 
 void foo(_AS3 float *a) {
-  _AS2 *x;
+  _AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
   _AS1 float * _AS2 *B;
 
   int _AS1 _AS2 *Y;   // expected-error {{multiple address spaces specified for type}}

Modified: cfe/trunk/test/Sema/block-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-literal.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-literal.c (original)
+++ cfe/trunk/test/Sema/block-literal.c Fri Feb 27 12:53:28 2009
@@ -40,7 +40,7 @@
 
 foo:
 	takeclosure(^{ x = 4; });  // expected-error {{variable is not assignable (missing __block type specifier)}}
-  __block y = 7;
+  __block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}}
   takeclosure(^{ y = 8; });
 }
 

Modified: cfe/trunk/test/Sema/implicit-int.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/implicit-int.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Sema/implicit-int.c (original)
+++ cfe/trunk/test/Sema/implicit-int.c Fri Feb 27 12:53:28 2009
@@ -1,4 +1,10 @@
-// RUN: clang -fsyntax-only %s
+// RUN: clang -fsyntax-only %s -verify -pedantic
 
-foo() {
+foo() { // expected-warning {{type specifier missing, defaults to 'int'}}
 }
+
+y;  // expected-warning {{type specifier missing, defaults to 'int'}}
+
+// rdar://6131634
+void f((x));  // expected-warning {{type specifier missing, defaults to 'int'}}
+

Modified: cfe/trunk/test/Sema/invalid-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-decl.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Sema/invalid-decl.c (original)
+++ cfe/trunk/test/Sema/invalid-decl.c Fri Feb 27 12:53:28 2009
@@ -6,7 +6,7 @@
 
 
 // PR2400
-typedef xtype (*zend_stream_fsizer_t)(void* handle); // expected-error {{function cannot return array or function type}}
+typedef xtype (*zend_stream_fsizer_t)(void* handle); // expected-error {{function cannot return array or function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}}
 
 typedef struct _zend_module_entry zend_module_entry;
 struct _zend_module_entry {

Modified: cfe/trunk/test/Sema/invalid-struct-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-struct-init.c?rev=65647&r1=65646&r2=65647&view=diff

==============================================================================
--- cfe/trunk/test/Sema/invalid-struct-init.c (original)
+++ cfe/trunk/test/Sema/invalid-struct-init.c Fri Feb 27 12:53:28 2009
@@ -3,7 +3,10 @@
 typedef struct _zend_module_entry zend_module_entry;
 struct _zend_module_entry {
   _efree((p)); // expected-error{{type name requires a specifier or qualifier}} \
-               // expected-error{{field '_efree' declared as a function}}
+                  expected-error{{field '_efree' declared as a function}} \
+                  expected-warning {{type specifier missing, defaults to 'int'}} \
+                  expected-warning {{type specifier missing, defaults to 'int'}}
+  
 };
 typedef struct _zend_function_entry { } zend_function_entry;
 typedef struct _zend_pcre_globals { } zend_pcre_globals;





More information about the cfe-commits mailing list