From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37011 invoked by alias); 24 Apr 2017 19:27:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 36993 invoked by uid 89); 24 Apr 2017 19:27:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Apr 2017 19:27:50 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 202FD7D0D0 for ; Mon, 24 Apr 2017 19:27:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 202FD7D0D0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dmalcolm@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 202FD7D0D0 Received: from c64.redhat.com (ovpn-112-28.phx2.redhat.com [10.3.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E6BA174A4; Mon, 24 Apr 2017 19:27:50 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] C++: fix-it hint for removing stray semicolons Date: Mon, 24 Apr 2017 20:10:00 -0000 Message-Id: <1493063953-51717-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg01063.txt.bz2 Patch adds a fix-it hint to a pre-existing pedwarn to make it easier for IDEs to assist in fixing the mistake. Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. OK for trunk? gcc/cp/ChangeLog: * parser.c (cp_parser_member_declaration): Add fix-it hint for removing stray semicolons. gcc/testsuite/ChangeLog: * g++.dg/semicolon-fixits.C: New test case. --- gcc/cp/parser.c | 6 +++++- gcc/testsuite/g++.dg/semicolon-fixits.C | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/semicolon-fixits.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f164d7e..9d5baf8 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23123,7 +23123,11 @@ cp_parser_member_declaration (cp_parser* parser) { cp_token *token = cp_lexer_peek_token (parser->lexer); if (!in_system_header_at (token->location)) - pedwarn (token->location, OPT_Wpedantic, "extra %<;%>"); + { + gcc_rich_location richloc (token->location); + richloc.add_fixit_remove (); + pedwarn_at_rich_loc (&richloc, OPT_Wpedantic, "extra %<;%>"); + } } else { diff --git a/gcc/testsuite/g++.dg/semicolon-fixits.C b/gcc/testsuite/g++.dg/semicolon-fixits.C new file mode 100644 index 0000000..a9cc783 --- /dev/null +++ b/gcc/testsuite/g++.dg/semicolon-fixits.C @@ -0,0 +1,17 @@ +/* { dg-options "-fdiagnostics-show-caret -Wpedantic" } */ + +/* Struct with extra semicolon. */ +struct s1 { int i;; }; /* { dg-warning "19: extra .;." } */ +/* { dg-begin-multiline-output "" } + struct s1 { int i;; }; + ^ + - + { dg-end-multiline-output "" } */ + +/* Union with extra semicolon. */ +union u1 { int i;; }; /* { dg-warning "18: extra .;." } */ +/* { dg-begin-multiline-output "" } + union u1 { int i;; }; + ^ + - + { dg-end-multiline-output "" } */ -- 1.8.5.3