From patchwork Tue May 2 14:16:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 757622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wHNdk6rS6z9s3w for ; Wed, 3 May 2017 00:16:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="J9kZEHQH"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=Dohh9zwkBpPzAye sqiVo//xb2sqmHHCiR/+m1pCBz7FkjBNTlnfAkofUDptaY9NHnywGho02squGUQd /dOvDjDiM/LR/gw1XD2soM53syhomC0s2Pt/LKB4BVLYSs4JvpUqOqsBkT9+975H 6EJowEacEiqGXkij21HxvSr5CLe4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=3mFWmUzovcZe7YahndDno 1gqR58=; b=J9kZEHQHiuReEexkUaodWBK9hGHMdYVk6j07zLTZjKwsYSeogWhxI 7Z5vEBd+7+HPKhbGunzcoVgcMaij5kGGH/XMVbizWxk79gjnH7TuRgW6TYYw5CP4 b4R6FXend6chFhwWu6PJs8CrdbG/9L9t8Bu1i1ypvelQRUqC53tmFk= Received: (qmail 41669 invoked by alias); 2 May 2017 14:16:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 41633 invoked by uid 89); 2 May 2017 14:16:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:f8b0, upset, Hx-spam-relays-external:f8b0, Hx-spam-relays-external:sk:richard X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 May 2017 14:16:42 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37102) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d5YbZ-0002aM-V2 for gcc-patches@gnu.org; Tue, 02 May 2017 10:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5YbY-00015U-D6 for gcc-patches@gnu.org; Tue, 02 May 2017 10:16:41 -0400 Received: from mail-it0-x22a.google.com ([2607:f8b0:4001:c0b::22a]:36655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5YbY-00015M-7X for gcc-patches@gnu.org; Tue, 02 May 2017 10:16:40 -0400 Received: by mail-it0-x22a.google.com with SMTP id o5so7105813ith.1 for ; Tue, 02 May 2017 07:16:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=E73gxcHwezbEM9NQWBFMYhTgFKGmptv4JgIWPPHGbp8=; b=AJOxX10L4OQK/d3GM3Ng/Ni93cwkxfp+QB5K+BjQRsBEWfY3imDkSb/hY5t83iXEjf TrsL325W3Y28AORUv0JR94E879U3hGHpKWvuWMsJyS/C5SVadPL/WDOm2VyiLcrGFRWw TwakgSKpuE/YtOaaloGjl9LSFBNOyAnm7N0BsoaY9czYrM/le4bNj5IhlE+UCKGB3fMD 1tU4L8HqBC5pQcNPdAH8bSA6x5ik1WeGgzH6NBbYwv8XxBomdbW3Pp5PaXplkwPJHqmK agnVB6v71gVCNoHndp5DhVjYQIW5+RBrQQZDcY7sfKl1P5qpn9GzL1NqB+XmHJQg8eZO 9T7A== X-Gm-Message-State: AN3rC/4wImCVucD/C/1WP3Gp/yUEba0m+Q4aNg8kAaiidxdaE/h2jgH8 QZFYwAQ+iluMJZKO23UQf8hd3cNX3Q== X-Received: by 10.157.63.143 with SMTP id r15mr11118134otc.89.1493734599179; Tue, 02 May 2017 07:16:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.51.83 with HTTP; Tue, 2 May 2017 07:16:37 -0700 (PDT) In-Reply-To: <9e3b3ee6-0c67-f974-c38e-7f9f25249914@gmail.com> References: <9e3b3ee6-0c67-f974-c38e-7f9f25249914@gmail.com> From: Richard Biener Date: Tue, 2 May 2017 16:16:37 +0200 Message-ID: Subject: Re: [PATCH 1/5][GIMPLE FE] PR testsuite/80580. Handle missing labels in goto statements To: Mikhail Maltsev Cc: gcc-patches , Prathamesh Kulkarni X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::22a X-IsSubscribed: yes On Mon, May 1, 2017 at 8:04 PM, Mikhail Maltsev wrote: > The first problem happens because we don't check for missing labels when parsing > 'goto' statements. I.e.: > > __GIMPLE() void fn1() { > if (1) > goto > } > > The fix is pretty obvious: just add a check. > My question is: which functions should I use to produce diagnostics? The > surrounding code uses 'c_parser_error', but this function does not handle > locations very well (in fact, it uses input_location). Certainly an improvement. I suppose we can do better error recovery for cases like if (1) goto else goto bar; but I guess this is better than nothing. And yes, we use c_parser_error -- input_location should be ok but here we just peek which may upset the parser. Maybe it works better when consuming the token before issueing the error? Thus ? Patch is ok with or without this adjustment (and testcase adjustment). Thanks, Richard. > -- > Regards, > Mikhail Maltsev > > gcc/testsuite/ChangeLog: > > 2017-05-01 Mikhail Maltsev > > * gcc.dg/gimplefe-error-4.c: New test. > * gcc.dg/gimplefe-error-5.c: New test. > > > gcc/c/ChangeLog: > > 2017-05-01 Mikhail Maltsev > > * gimple-parser.c (c_parser_gimple_if_stmt): Check for empty labels. > > Index: gcc/c/gimple-parser.c =================================================================== --- gcc/c/gimple-parser.c (revision 247498) +++ gcc/c/gimple-parser.c (working copy) @@ -1315,8 +1315,8 @@ c_parser_gimple_if_stmt (c_parser *parse loc = c_parser_peek_token (parser)->location; c_parser_consume_token (parser); label = c_parser_peek_token (parser)->value; - t_label = lookup_label_for_goto (loc, label); c_parser_consume_token (parser); + t_label = lookup_label_for_goto (loc, label); if (! c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) return; }