From: Douglas Gregor Date: Thu, 8 Apr 2010 21:33:23 +0000 (+0000) Subject: Downgrade the "declaration does not declare anything" error to a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb821d045f5e445384f34d05a526955036073c4a;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100814 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index 1402e96ce0..5e28f49ade 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -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">; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 82cecc3f4d..9d0d7ad133 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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); diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 576e57d071..4abbbc5b9b 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -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: diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp index 3f8f1ec9d0..3a97efac19 100644 --- a/test/Parser/cxx-template-decl.cpp +++ b/test/Parser/cxx-template-decl.cpp @@ -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 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