From patchwork Sat Sep 21 14:02:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1165588 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-509398-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ih6nPG2P"; 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 46bC304Y5tz9s00 for ; Sun, 22 Sep 2019 00:02:50 +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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=juW8BA7vcnRWPp4/fh76qtXICS5gXUYFpoiOiVx3YfqYrNzWdz YS1Rbma2ICZoYPrbgMerqZBJ8HKH3o2T8F6XZ1DyZJF2WgRIljX8kLiRHV8qOKm2 dvKEjAur9icgO7RW35UswDGP8gE5OFvxW2yj712Z/yCIOIt+OlkrWtAbs= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=dThlHcVSEYxzbm7E/xylxC+9iKE=; b=ih6nPG2PPmbTRDiIf0Dh WqrPji53ki5KP/cH/u0MU3gxlBt44+pm74KstVl2jEkcPUGoZ6YWFbUZ5QN+NiR2 gAOizOSeJOYQKEDbBF2f7RIGfbgHn5MoYG7HFcflUeHqg5UaDP0RsF1DOq4IGL7h vp7mZFIQi74s9Y1qqspc3P8= Received: (qmail 70984 invoked by alias); 21 Sep 2019 14:02:41 -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 70971 invoked by uid 89); 21 Sep 2019 14:02:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=jumping 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; Sat, 21 Sep 2019 14:02:40 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 603CE3086218 for ; Sat, 21 Sep 2019 14:02:39 +0000 (UTC) Received: from redhat.com (ovpn-120-96.rdu2.redhat.com [10.10.120.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B50FD1001938; Sat, 21 Sep 2019 14:02:38 +0000 (UTC) Date: Sat, 21 Sep 2019 10:02:36 -0400 From: Marek Polacek To: GCC Patches Cc: Jason Merrill Subject: C++ PATCH to add test for DR 2345 Message-ID: <20190921140236.GW14737@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Jumping across initializers is forbidden, and this DR clarifies that that applies to initializers in init-statements too. We already detect this case, so I'm adding this test and marking the DR as resolved. Tested on x86_64-linux, applying to trunk. 2019-09-21 Marek Polacek DR 2345 - Jumping across initializers in init-statements and conditions. * g++.dg/cpp1z/init-statement10.C: New test. diff --git gcc/testsuite/g++.dg/cpp1z/init-statement10.C gcc/testsuite/g++.dg/cpp1z/init-statement10.C new file mode 100644 index 00000000000..d13d135dab1 --- /dev/null +++ gcc/testsuite/g++.dg/cpp1z/init-statement10.C @@ -0,0 +1,14 @@ +// DR 2345 - Jumping across initializers in init-statements and conditions. +// { dg-do compile { target c++17 } } + +int +fn () +{ + goto X; + if (int i = 42; i == 42) + { +X: // { dg-error "jump to label" } + return i; + } + return -1; +}