From f19ac0ede900dae8188eae0362027e60bfa82a32 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 8 Apr 2010 21:33:23 +0000 Subject: [PATCH] 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. llvm-svn: 100814 --- clang/include/clang/Basic/DiagnosticCommonKinds.td | 2 +- clang/lib/Sema/SemaDecl.cpp | 5 ++--- clang/test/Parser/cxx-class.cpp | 2 +- clang/test/Parser/cxx-template-decl.cpp | 2 +- clang/test/Sema/anonymous-struct-union.c | 10 +++++----- clang/test/Sema/decl-invalid.c | 12 ++++++------ clang/test/Sema/declspec.c | 2 +- clang/test/SemaCXX/anonymous-union.cpp | 2 +- clang/test/SemaCXX/class.cpp | 2 +- clang/test/SemaObjC/property-9.m | 4 ++-- clang/test/SemaTemplate/template-decl-fail.cpp | 2 +- 11 files changed, 22 insertions(+), 23 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index 1402e96ce08a..5e28f49adeea 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/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/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 82cecc3f4d02..9d0d7ad13307 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp index 576e57d0716a..4abbbc5b9b58 100644 --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/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/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp index 3f8f1ec9d0be..3a97efac19ed 100644 --- a/clang/test/Parser/cxx-template-decl.cpp +++ b/clang/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