From patchwork Thu Apr 3 15:24:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 336657 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 1B6D814007C for ; Fri, 4 Apr 2014 02:25:02 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=dxzIUoVFweEO AtK2mBoCRlCheSG6+Xk0+TkbSuFj2BkdfOAffCQ6I1hYdiNDzyoJabMbqku8H1VV Q/vkgMNjdlRVPsbE1xvRDH3BgZRyntktZy8gIpAsQqSLH6396jWySP1Ar4k9kwQS 9U+IEB5qPnhziwtbYdSXv/oMOYlpMSw= 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:from :to:cc:subject:date:message-id; s=default; bh=j7XDENBUzrPdswdY/k IxLWv6U9s=; b=cc7z3eGF3eHvGU2anJResk1BXJbaZBGvC+kpAKxdShU1qgd6Rf xFhsgHlTvuwwAfjuGutDUg1lL1vNgzF8Cz5bPet6tTugJb6+vlGVdPArAXmmcLNs 3LUWERTSvqB0xsXQ+xn7mTkAuiLZLSA2IiheEdu/E9Drhg87J1SjPYcj8= Received: (qmail 32707 invoked by alias); 3 Apr 2014 15:24:55 -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 32693 invoked by uid 89); 3 Apr 2014 15:24:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-qc0-f178.google.com Received: from mail-qc0-f178.google.com (HELO mail-qc0-f178.google.com) (209.85.216.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 03 Apr 2014 15:24:53 +0000 Received: by mail-qc0-f178.google.com with SMTP id i8so2005600qcq.23 for ; Thu, 03 Apr 2014 08:24:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=udE2WQquQhk1HFA9BSor513K/IL4RSTIPT62GGdkFk0=; b=Do+MlWEq8DWCaNxUk4sVpetxatPvOilYTI/WsFTuXmE9UQsQ38xvnDSPBJRtypBnVK ok17GLANxwYXk8fe56BaMY6od/NFJyjvNU2Q0Dh1Vk632186oVMwbRIutudJ3KqXo13E n4mpgVxAuJY5EA0+wm1AqU5UU9tKoMUvnUR6maPMJUxK+x4HU9Ht9/mpVk5qxJgmVtdd vv6jJ07CBnVoVHV4yTGsPsxkGV9E2sIdWzDVnelMLGyZbba74a6+LnLMsCzFaqrI+B4A Kww2CDeXq+veo37qvrkfmYAS57E1nRT4YUmOiSVccgm+rP/Y7F8q22DL2VyFZOrbq6lq 76Lg== X-Gm-Message-State: ALoCoQlwCvcEskgt7wgJ6GQtgEXz84VRYKZPGAzXGJExQjsSKeoo6/Lefkdtq0B/pfh/UfqlJpog X-Received: by 10.140.97.183 with SMTP id m52mr1907518qge.108.1396538691204; Thu, 03 Apr 2014 08:24:51 -0700 (PDT) Received: from localhost.localdomain (ool-4353a9c4.dyn.optonline.net. [67.83.169.196]) by mx.google.com with ESMTPSA id i9sm7264168qgd.3.2014.04.03.08.24.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Apr 2014 08:24:48 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] Fix PR c++/21113 Date: Thu, 3 Apr 2014 11:24:41 -0400 Message-Id: <1396538682-31474-1-git-send-email-patrick@parcs.ath.cx> Hi, This patch fixes c++/21113 which reports that the C++ frontend does not forbid jumps into the scope of identifiers with variably-modified types. The patch simply augments decl_jump_unsafe() to disallow jumping into blocks that initialize variably-modified decls. I bootstrapped and regtested this change on x86_64-unknown-linux-gnu. 2014-04-03 Patrick Palka PR c++/21113 * decl.c (decl_jump_unsafe): Consider variably-modified decls. --- gcc/cp/decl.c | 5 ++--- gcc/testsuite/g++.dg/ext/vla14.C | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/vla14.C diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5bd33c5..6571af5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2785,9 +2785,8 @@ decl_jump_unsafe (tree decl) || type == error_mark_node) return 0; - type = strip_array_types (type); - - if (DECL_NONTRIVIALLY_INITIALIZED_P (decl)) + if (DECL_NONTRIVIALLY_INITIALIZED_P (decl) + || variably_modified_type_p (type, NULL_TREE)) return 2; if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) diff --git a/gcc/testsuite/g++.dg/ext/vla14.C b/gcc/testsuite/g++.dg/ext/vla14.C new file mode 100644 index 0000000..278cb63 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vla14.C @@ -0,0 +1,23 @@ +// PR c++/21113 +// { dg-options "" } + +void +f (int n) +{ + goto label; // { dg-error "from here" } + int a[n]; // { dg-error "crosses initialization" } +label: // { dg-error "jump to label" } + ; +} + +void +g (int n) +{ + switch (1) + { + case 1: + int (*a)[n]; // { dg-error "crosses initialization" } + default: // { dg-error "jump to case label" } + ; + } +}