From patchwork Tue Feb 27 02:38:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 878302 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-473909-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="hnT/V8LA"; 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 3zr2v14Mtcz9s1B for ; Tue, 27 Feb 2018 13:38:37 +1100 (AEDT) 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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=GqDzgT7bNhstiuGXN6k4IVxnAprKz64NQanNJECz9DCx2Y IdmzQNHLv10HwyQFev5dVKacbiFFXyoX1qlmHgO8JPOHUbSQEobij3cjd4Z0qrCR wVuwIf+q2z7+6uYtnjJzaEJ3+/iOQAW7aeLATRUF23appUgFFzxJ/YHdXgU8E= 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:from:date:message-id:subject:to:content-type; s= default; bh=oOSuwyrGm4M1HEm1VLs9Ub8ZvBI=; b=hnT/V8LAU8Dv/c5M7kLj B3cbBwYHjj9jFnxMoNNZu2ewDOuAihRgWio3PbF0FT9t6vbDsJuzC7wfam04t/Tb 3U6/jnp8BcZe+vAjXFgz/XRB+jQkNrY1tPA6cdor5rtIfwAeVEq9I2xA0tVO3huL sLcosTYd7lSrp8ncQ+QLg50= Received: (qmail 29985 invoked by alias); 27 Feb 2018 02:38:30 -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 29970 invoked by uid 89); 27 Feb 2018 02:38:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-it0-f47.google.com Received: from mail-it0-f47.google.com (HELO mail-it0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Feb 2018 02:38:28 +0000 Received: by mail-it0-f47.google.com with SMTP id k79so10588579ita.2 for ; Mon, 26 Feb 2018 18:38:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/w+fAf63UcJGUuI6mHX5Xueer8zA7kW+rkcFhMgcFDE=; b=MIZ9uS5hm5DXSe6lLyirgyNWZM7BYbxSdFr6aCBk9ozizLpdCT067x0/pdIVt7Srdp 1d67f5NdvufdOHZwCOzmwUKm+dseE5ax9rspg40yK8XzAkefEc1i1oGYlxq0Pbcl7XZs 4R4qt+l0TONmm2koGlg4aVZyKSj0lD2pFqeLXtgS2lDpsIEXTgDenS/RgHN63sKGZNNv bgXkp6gqUe6BLLgMrkSz+MLQLJ3blh5pJSZURM4OC7GWB4wr4O9+fwvz8eR8JWwybX9q 6mGxTEmsQCcXNW/w7JiWl7vqRYroGhWgwDGHwc624wBZwgE3FeXt+ONDoncIvrieHnfh 2XZA== X-Gm-Message-State: APf1xPAbI8Ue4vZ2Qj4jBna8hS/AEN53vbCVj9EFCWHkfJNCMo9fXY+g 8u3fGUO2ixrBvdHqBcDjQctlEOTbOXQQg//FqJHUEJvh X-Google-Smtp-Source: AG47ELuy7UzkpWj6EgNuZU0kjHNYsOurYgDN9kYoeHYN7Trf81/qRzAtr0bdQh4RhqnZWLHZ3tPSfs/zWbsSjV8cwiU= X-Received: by 10.36.36.144 with SMTP id f138mr3838911ita.131.1519699106817; Mon, 26 Feb 2018 18:38:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.17.200 with HTTP; Mon, 26 Feb 2018 18:38:06 -0800 (PST) From: Jason Merrill Date: Mon, 26 Feb 2018 21:38:06 -0500 Message-ID: Subject: C++ PATCH for c++/84560, ICE capturing multi-dimensional VLA To: gcc-patches List X-IsSubscribed: yes The code was already there to give an error for this case, we just weren't hitting it because array_of_runtime_bound_p was incorrectly returning true. Tested x86_64-pc-linux-gnu, applying to trunk. commit 1106dfa9e9df6e4dddb75c50db57cff953017fc7 Author: Jason Merrill Date: Mon Feb 26 20:42:13 2018 -0500 PR c++/84560 - ICE capturing multi-dimensional VLA. * tree.c (array_of_runtime_bound_p): False if the element is variably-modified. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 41d9002d8f9..9b9e36a1173 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1043,6 +1043,8 @@ array_of_runtime_bound_p (tree t) { if (!t || TREE_CODE (t) != ARRAY_TYPE) return false; + if (variably_modified_type_p (TREE_TYPE (t), NULL_TREE)) + return false; tree dom = TYPE_DOMAIN (t); if (!dom) return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C new file mode 100644 index 00000000000..d4de131fc23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C @@ -0,0 +1,12 @@ +// PR c++/84560 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +void f() { + int n = 1; + int m = 1; + int d[n][m]; + [&]() { + return d[1]; // { dg-error "variabl" } + }(); +}