[cfe-commits] r100814 - in /cfe/trunk: 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
Douglas Gregor
dgregor at apple.com
Thu Apr 8 14:33:23 PDT 2010
Author: dgregor
Date: Thu Apr 8 16:33:23 2010
New Revision: 100814
URL: http://llvm.org/viewvc/llvm-project?rev=100814&view=rev
Log:
Downgrade the "declaration does not declare anything" error to a
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Parser/cxx-class.cpp
cfe/trunk/test/Parser/cxx-template-decl.cpp
cfe/trunk/test/Sema/anonymous-struct-union.c
cfe/trunk/test/Sema/decl-invalid.c
cfe/trunk/test/Sema/declspec.c
cfe/trunk/test/SemaCXX/anonymous-union.cpp
cfe/trunk/test/SemaCXX/class.cpp
cfe/trunk/test/SemaObjC/property-9.m
cfe/trunk/test/SemaTemplate/template-decl-fail.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Apr 8 16:33:23 2010
@@ -41,7 +41,7 @@
"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">;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Apr 8 16:33:23 2010
@@ -1459,7 +1459,7 @@
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 @@
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);
Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Thu Apr 8 16:33:23 2010
@@ -8,7 +8,7 @@
struct S {};
enum {};
- int; // expected-error {{declaration does not declare anything}}
+ int; // expected-warning {{declaration does not declare anything}}
int : 1, : 2;
public:
Modified: cfe/trunk/test/Parser/cxx-template-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-template-decl.cpp?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-template-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-template-decl.cpp Thu Apr 8 16:33:23 2010
@@ -6,7 +6,7 @@
// 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 '>'}} \
Modified: cfe/trunk/test/Sema/anonymous-struct-union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/anonymous-struct-union.c?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/Sema/anonymous-struct-union.c (original)
+++ cfe/trunk/test/Sema/anonymous-struct-union.c Thu Apr 8 16:33:23 2010
@@ -50,12 +50,12 @@
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 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 @@
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 @@
};
// PR3680
-struct {}; // expected-error{{declaration does not declare anything}}
+struct {}; // expected-warning{{declaration does not declare anything}}
struct s2 {
union {
Modified: cfe/trunk/test/Sema/decl-invalid.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-invalid.c?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/Sema/decl-invalid.c (original)
+++ cfe/trunk/test/Sema/decl-invalid.c Thu Apr 8 16:33:23 2010
@@ -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 @@
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}}
Modified: cfe/trunk/test/Sema/declspec.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/declspec.c?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/Sema/declspec.c (original)
+++ cfe/trunk/test/Sema/declspec.c Thu Apr 8 16:33:23 2010
@@ -10,7 +10,7 @@
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) { }
Modified: cfe/trunk/test/SemaCXX/anonymous-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/anonymous-union.cpp?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/anonymous-union.cpp (original)
+++ cfe/trunk/test/SemaCXX/anonymous-union.cpp Thu Apr 8 16:33:23 2010
@@ -110,7 +110,7 @@
};
// <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 ;
Modified: cfe/trunk/test/SemaCXX/class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class.cpp?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/class.cpp (original)
+++ cfe/trunk/test/SemaCXX/class.cpp Thu Apr 8 16:33:23 2010
@@ -103,7 +103,7 @@
// 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 {
Modified: cfe/trunk/test/SemaObjC/property-9.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-9.m?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-9.m (original)
+++ cfe/trunk/test/SemaObjC/property-9.m Thu Apr 8 16:33:23 2010
@@ -43,9 +43,9 @@
int _awesome;
}
- at property (readonly) int; // expected-error {{declaration does not declare anything}}
+ at 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}}
Modified: cfe/trunk/test/SemaTemplate/template-decl-fail.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/template-decl-fail.cpp?rev=100814&r1=100813&r2=100814&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/template-decl-fail.cpp (original)
+++ cfe/trunk/test/SemaTemplate/template-decl-fail.cpp Thu Apr 8 16:33:23 2010
@@ -4,5 +4,5 @@
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}}
More information about the cfe-commits
mailing list