From patchwork Thu Aug 9 12:07:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 955492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483450-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JYsyVnHY"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="YOuKv39v"; dkim-atps=neutral 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 41mRq129V9z9ryt for ; Thu, 9 Aug 2018 22:08:12 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=OR99UWukACTwC8qPfK+Z/T3BHRteM6r7tvSE+c/5Z2OZAQ6Xl5 JuXt+EKNgPvMeO/wZ5nMqh2jRRU8+AmTO1Xng/Y3pQ9dD9/rve1d1+64NSxiwVo6 4EXKbHTQ3rLOKL4V87HrGQzXzbowKKacCig1dL4HbalZnc86Mk7sSGVmc= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=we8PCNoDB2H6ySrOWPECEoGPuXU=; b=JYsyVnHYhW2VIV6MPIGM 2UUjvvxYF1A1oTe0TdHJzVHf3v5COK/E8UhhbnluELyjcYOJhVUu67yI5xG/VZr7 USGPhFw/mb/DY76uY2sdJDn7xeh2Rfs8WEZ7gMkuvDKOcC+0KcDQRlAHenBPZ56W rwJtspezeUNXvaY4pWeKk0k= Received: (qmail 66772 invoked by alias); 9 Aug 2018 12:08:05 -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 66761 invoked by uid 89); 9 Aug 2018 12:08:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Aug 2018 12:08:03 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w79C3o85152698; Thu, 9 Aug 2018 12:07:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=ONrej5Rne0iNVTcyafDg11pFQz8weZfp6PVC3UvCpvI=; b=YOuKv39v8wK3k03VM95KBNuJtl+uZYu8+NysrVvysXljzHKnFGyvfxcF6AB1hhXtoXyV /lgK2g28xvyocHfJuno2ZzsyhBBo/9PvwQNXW2+sG69VaUz3udIBAms6a8s0cvhmWhkJ LI1PQ29WeBt0dsfBtuok0hnPwaHT1ChrNvEuXCy/Jq3HKM/2ZpT1YEb7HtFl05H+FXow jqWn29Y6zpGL54+KB0pe0MGMce9vt20q0eD2j0sKtgYcQyx2GciYhC09CtlBHj0oTfXL yGHL25SLtnK/iWSlZ7VXriYVsxj9qxZwlmufcXjPw9Ejg2DLP6+MJBT8UAbHwd5C40Yp zQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2kn4sq2uj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Aug 2018 12:07:59 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w79C7wrj001926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Aug 2018 12:07:59 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w79C7vWj016042; Thu, 9 Aug 2018 12:07:57 GMT Received: from [192.168.1.4] (/95.248.131.198) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Aug 2018 05:07:56 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] Tweak check_previous_goto_1 to emit hard errors instead of permerrors in some cases Message-ID: Date: Thu, 9 Aug 2018 14:07:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, over the years we reworked and improved the code in decl.c checking gotos quite a bit. Lately, in some specific unsafe cases, identify_goto issues upfront an error instead of a permerror, whereas it used to always issue a permerror. Over the last weeks a few colleagues of mine noticed that we don't do that, escalating a permerror to a plain error, in a case which is certainly unsafe - decl_jump_unsafe returns 2 - thus, if the user passes -fpermissive we end up emitting assembly completely missing labels. The straightforward patchlet below passes testing on x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2018-08-09 Paolo Carlini * decl.c (check_previous_goto_1): When decl_jump_unsafe returns 2 emit an error instead of a permerror. /testsuite 2018-08-09 Paolo Carlini * g++.dg/init/goto3.C: Adjust for error intead of permerror. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 263443) +++ cp/decl.c (working copy) @@ -3191,7 +3191,8 @@ check_previous_goto_1 (tree decl, cp_binding_level if (!identified) { complained = identify_goto (decl, input_location, locus, - DK_PERMERROR); + problem > 1 + ? DK_ERROR : DK_PERMERROR); identified = 1; } if (complained) Index: testsuite/g++.dg/init/goto3.C =================================================================== --- testsuite/g++.dg/init/goto3.C (revision 263443) +++ testsuite/g++.dg/init/goto3.C (working copy) @@ -15,11 +15,11 @@ adapt_parameters_next_iteration(void) case VAR_NONE: break; case VAR_DELTA: - int trunc_n_ants = 0; + int trunc_n_ants = 0; // { dg-message "initialization" } n_ants += trunc_n_ants; break; - case VAR_SWITCH: + case VAR_SWITCH: // { dg-error "jump" } break; - default: break; + default: break; // { dg-error "jump" } } }