From: Douglas Gregor Date: Wed, 16 Jun 2010 23:08:59 +0000 (+0000) Subject: Make the "extra ';' inside a struct or union" diagnostic more X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f13ca06e57ac094ed05ea08c26a499af1ba0ce88;p=clang Make the "extra ';' inside a struct or union" diagnostic more precise. Fixes PR7336. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106170 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 42080d5c4c..e4f9092628 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -24,7 +24,9 @@ def ext_empty_source_file : Extension<"ISO C forbids an empty source file">; def ext_top_level_semi : Extension< "extra ';' outside of a function">; def ext_extra_struct_semi : Extension< - "extra ';' inside a struct or union">; + "extra ';' inside a %0">; +def ext_extra_ivar_semi : Extension< + "extra ';' inside instance variable list">; def ext_duplicate_declspec : Extension<"duplicate '%0' declaration specifier">; def ext_plain_complex : ExtWarn< diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 532aff797f..65c42193f6 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1777,6 +1777,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, // Check for extraneous top-level semicolon. if (Tok.is(tok::semi)) { Diag(Tok, diag::ext_extra_struct_semi) + << DeclSpec::getSpecifierName((DeclSpec::TST)TagType) << FixItHint::CreateRemoval(Tok.getLocation()); ConsumeToken(); continue; diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 9cf025df5e..fe3122645b 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1570,6 +1570,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, // Check for extraneous top-level semicolon. if (Tok.is(tok::semi)) { Diag(Tok, diag::ext_extra_struct_semi) + << DeclSpec::getSpecifierName((DeclSpec::TST)TagType) << FixItHint::CreateRemoval(Tok.getLocation()); ConsumeToken(); continue; diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 365733d8c4..8e32653126 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1014,7 +1014,7 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl, // Check for extraneous top-level semicolon. if (Tok.is(tok::semi)) { - Diag(Tok, diag::ext_extra_struct_semi) + Diag(Tok, diag::ext_extra_ivar_semi) << FixItHint::CreateRemoval(Tok.getLocation()); ConsumeToken(); continue; diff --git a/test/Index/code-complete-errors.c b/test/Index/code-complete-errors.c index 29c2a86198..01c298c01d 100644 --- a/test/Index/code-complete-errors.c +++ b/test/Index/code-complete-errors.c @@ -1,7 +1,7 @@ _Complex cd; // CHECK: code-complete-errors.c:1:1: warning: plain '_Complex' requires a type specifier; assuming '_Complex double' // CHECK: FIX-IT: Insert " double" at 1:9 struct s { - int x, y;; // CHECK: code-complete-errors.c:4:12: warning: extra ';' inside a struct or union + int x, y;; // CHECK: code-complete-errors.c:4:12: warning: extra ';' inside a struct }; // CHECK: FIX-IT: Remove [4:12 - 4:13] struct s s0 = { y: 5 }; // CHECK: code-complete-errors.c:7:20: warning: use of GNU old-style field designator extension