]> granicus.if.org Git - clang/commitdiff
Downgrade the "declaration does not declare anything" error to a
authorDouglas Gregor <dgregor@apple.com>
Thu, 8 Apr 2010 21:33:23 +0000 (21:33 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 8 Apr 2010 21:33:23 +0000 (21:33 +0000)
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100814 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticCommonKinds.td
lib/Sema/SemaDecl.cpp
test/Parser/cxx-class.cpp
test/Parser/cxx-template-decl.cpp
test/Sema/anonymous-struct-union.c
test/Sema/decl-invalid.c
test/Sema/declspec.c
test/SemaCXX/anonymous-union.cpp
test/SemaCXX/class.cpp
test/SemaObjC/property-9.m
test/SemaTemplate/template-decl-fail.cpp

index 1402e96ce08a53f77e740bb712731ac708dca607..5e28f49adeea16a57b6238e3f740695dd8febba9 100644 (file)
@@ -41,7 +41,7 @@ def err_expected_colon_after_setter_name : Error<
   "must end with ':'">;
 
 // Parse && Sema
-def err_no_declarators : Error<"declaration does not declare anything">;
+def ext_no_declarators : ExtWarn<"declaration does not declare anything">;
 def err_param_redefinition : Error<"redefinition of parameter %0">;
 def err_invalid_storage_class_in_func_decl : Error<
   "invalid storage class specifier in function declarator">;
index 82cecc3f4d02a08fdb891b2db8e407f98192c53f..9d0d7ad13307b239e4cfc2fa1aa752f1b75b2d7a 100644 (file)
@@ -1459,7 +1459,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
           Record->getDeclContext()->isRecord())
         return BuildAnonymousStructOrUnion(S, DS, Record);
 
-      Diag(DS.getSourceRange().getBegin(), diag::err_no_declarators)
+      Diag(DS.getSourceRange().getBegin(), diag::ext_no_declarators)
         << DS.getSourceRange();
     }
 
@@ -1481,9 +1481,8 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
       return DeclPtrTy::make(Tag);
     }
 
-    Diag(DS.getSourceRange().getBegin(), diag::err_no_declarators)
+    Diag(DS.getSourceRange().getBegin(), diag::ext_no_declarators)
       << DS.getSourceRange();
-    return DeclPtrTy();
   }
 
   return DeclPtrTy::make(Tag);
index 576e57d0716a9e3f1fbf5ed520f456d756acaf43..4abbbc5b9b580a33f1fcd885f7c613cfe13504a5 100644 (file)
@@ -8,7 +8,7 @@ protected:
 
   struct S {};
   enum {};
-  int; // expected-error {{declaration does not declare anything}}
+  int; // expected-warning {{declaration does not declare anything}}
   int : 1, : 2;
 
 public:
index 3f8f1ec9d0be9f011808e8c09daf99acf3006c22..3a97efac19ed45076966d71a918afa6096d1982b 100644 (file)
@@ -6,7 +6,7 @@ template  x;            // expected-error {{C++ requires a type specifier for al
                         // expected-error {{does not refer}}
 export template x;      // expected-error {{expected '<' after 'template'}}
 export template<class T> class x0; // expected-warning {{exported templates are unsupported}}
-template < ;            // expected-error {{parse error}} expected-error {{declaration does not declare anything}}
+template < ;            // expected-error {{parse error}} expected-warning {{declaration does not declare anything}}
 template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
 // expected-error{{extraneous}}
 template <template <typename> > struct Err2;       // expected-error {{expected 'class' before '>'}} \
index 78995a993a4f5116769e9043a0d37d63a0c3d6f7..118854fd47233bdc71c243575300764b0dcb6b8c 100644 (file)
@@ -50,12 +50,12 @@ struct Redecl {
   void zz(); // expected-error{{duplicate member 'zz'}} 
 };
 
-union { // expected-error{{declaration does not declare anything}}
+union { // expected-warning{{declaration does not declare anything}}
   int int_val;
   float float_val;
 };
 
-static union { // expected-error{{declaration does not declare anything}}
+static union { // expected-warning{{declaration does not declare anything}}
   int int_val2;
   float float_val2;
 };
@@ -66,7 +66,7 @@ void f() {
 }
 
 void g() {
-  union { // expected-error{{declaration does not declare anything}}
+  union { // expected-warning{{declaration does not declare anything}}
     int i;
     float f2;
   };
@@ -78,7 +78,7 @@ void g() {
 struct s0 { union { int f0; }; };
 
 // <rdar://problem/6481130>
-typedef struct { }; // expected-error{{declaration does not declare anything}}
+typedef struct { }; // expected-warning{{declaration does not declare anything}}
 
 // PR3675
 struct s1 {
@@ -89,7 +89,7 @@ struct s1 {
 };
 
 // PR3680
-struct {}; // expected-error{{declaration does not declare anything}}
+struct {}; // expected-warning{{declaration does not declare anything}}
 
 struct s2 {
   union {
index 815e6dd9ca508abbd5c533f5c8247a2e83b1cb06..f6fed3c92d0d9f658ee8bcb8e0811b8abfef1b74 100644 (file)
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
 
 // See Sema::ParsedFreeStandingDeclSpec about the double diagnostic
-typedef union <anonymous> __mbstate_t;  // expected-error {{declaration of anonymous union must be a definition}} expected-error {{declaration does not declare anything}}
+typedef union <anonymous> __mbstate_t;  // expected-error {{declaration of anonymous union must be a definition}} expected-warning {{declaration does not declare anything}}
 
 
 // PR2017
@@ -13,12 +13,12 @@ int a() {
                  expected-error{{expected identifier or '('}}
 }
 
-int; // expected-error {{declaration does not declare anything}}
-typedef int; // expected-error {{declaration does not declare anything}}
-const int; // expected-error {{declaration does not declare anything}}
-struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-error {{declaration does not declare anything}}
+int; // expected-warning {{declaration does not declare anything}}
+typedef int; // expected-warning {{declaration does not declare anything}}
+const int; // expected-warning {{declaration does not declare anything}}
+struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-warning {{declaration does not declare anything}}
 typedef int I;
-I; // expected-error {{declaration does not declare anything}}
+I; // expected-warning {{declaration does not declare anything}}
 
 
 
index 1c87a0e21c5da5c97159152c8a6e8ee074df8eb4..7354028cba392244b9b32cfbd6a20b7c6d5ebd33 100644 (file)
@@ -10,7 +10,7 @@ int typedef validTypeDecl() { } // expected-error {{function definition declared
 struct _zend_module_entry { }    // expected-error {{expected ';' after struct}}
 int gv1;
 typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
-                                        // expected-error {{declaration does not declare anything}}
+                                        // expected-warning {{declaration does not declare anything}}
 int gv2;
 
 static void buggy(int *x) { }
index 0590db28d83266287ae77307ddf4047d3b3a4476..5c34e016e57de19ebe57c6e76853d3d67d3b92e1 100644 (file)
@@ -110,7 +110,7 @@ struct BadMembers {
 };
 
 // <rdar://problem/6481130>
-typedef union { }; // expected-error{{declaration does not declare anything}}
+typedef union { }; // expected-warning{{declaration does not declare anything}}
 
 // <rdar://problem/7562438>
 typedef struct objc_module *Foo ;
index 508ca4d7652a5bf7102462ccffdbb5b1984a7d29..7eea67ad4455d83fbee63c1729dd7032c4dd1ab3 100644 (file)
@@ -103,7 +103,7 @@ void ogfn()
 
   // PR3020: This used to crash due to double ownership of C4.
   struct C4;
-  C4; // expected-error {{declaration does not declare anything}}
+  C4; // expected-warning {{declaration does not declare anything}}
 }
 
 struct C4 {
index d527a9c9f30b634b954fae3eb1759bff063ae42b..669f9c0e4bd07e47651fd8d1ddb02c0f7d11492c 100644 (file)
@@ -43,9 +43,9 @@ typedef signed char BOOL;
  int _awesome;
 }
 
-@property (readonly) int; // expected-error {{declaration does not declare anything}}
+@property (readonly) int; // expected-warning {{declaration does not declare anything}}
 @property (readonly) ; // expected-error {{type name requires a specifier or qualifier}} \
-                          expected-error {{declaration does not declare anything}}
+                          expected-warning {{declaration does not declare anything}}
 @property (readonly) int : 4; // expected-error {{property requires fields to be named}}
 
 
index eca0f58831a901b8cc294a70052f84abd52006dc..7c04131eba271f5a8673d98ab7944c653e426959 100644 (file)
@@ -4,5 +4,5 @@ template<typename T> typedef T X; // expected-error{{typedef cannot be a templat
 
 template<typename T>
 enum t0 { A = T::x }; // expected-error{{enumeration cannot be a template}} \
-                      // expected-error{{declaration does not declare anything}}
+                      // expected-warning{{declaration does not declare anything}}