From patchwork Mon Mar 20 19:58:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 741154 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 3vn6G36WlXz9s76 for ; Tue, 21 Mar 2017 06:58:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Sd+YonW6"; 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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=EDe5z/8eur9cmhKMeMBV8xVvdUWX7Xr8CUxTXXgHjjdCK4 LkAU2hQsjC6Ho7KS1dT3+4AbEG84WATWOa67HLDZwu3OGwk482xjkQjZq4A5kBri JKFP6Sme/uUCgb4/9hT4d/eBsQV5UFo3MKV+DOscxy6E52tymXlcCyjr1+QvA= 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=2lcBipEQ8+vK3FWHojYtgPaQWuk=; b=Sd+YonW6IRC4C7QgTlA5 pH4pMmW0av6WB128U/b4uVhpb45JRE5oB0fKJ5TLLlKBkPw5QEGVG7WF27+oHIuA 9GDJhVDgm8+cY2gH/f4SnYcA9bTMllHvhal2UB9OoMozrywMu52lSZ6KJUxHwS/2 05X/cj0DgEUEZiVdWplEg7w= Received: (qmail 109865 invoked by alias); 20 Mar 2017 19:58:29 -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 109804 invoked by uid 89); 20 Mar 2017 19:58:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f54.google.com Received: from mail-oi0-f54.google.com (HELO mail-oi0-f54.google.com) (209.85.218.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Mar 2017 19:58:27 +0000 Received: by mail-oi0-f54.google.com with SMTP id r203so23499724oib.3 for ; Mon, 20 Mar 2017 12:58:28 -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:from:date:message-id:subject:to; bh=tH+SXmuyqsUkoAwj0P6nQbZPZXafkd2MKGH8sRWKOo8=; b=A2Q+pFXDpdBI9dM2qEdgNS8U2Lm3KCav4zGbTy8obgdkupBqX0xg0emGz+2CRpi4L+ b6nCcazADgjHBZUOUqKeab8EjjQcpcgKveRG1yD5QBfsUDFjK/I3X7ztAj7HzBPgs8sH dVSqOWrQdYwHQHYT6+JmU4zEoHsqeeZWQRlYaLSy6fol6FusHW1G/efGGJQCsorCZ+nd Uh2mX8GXTFMO/bjX2oS8UG3uYG29RTVHcCH34IF1pLkKse/IL8U8/PUTBd3Q92o+Wrq2 UZel6lNdkewPTrji9uoUEYlznX+0oCY+d7uEepxvnJ4O2aUah0b9qZTkTvtZF2BxxNVw Jehg== X-Gm-Message-State: AFeK/H1ky9TGepL1tb9rFNCRc4UaAHQoYJPVJbMegbsaxuP/xntNBuhCyWHqGSFI4suWZokUFjNtPauw/bmr3r+P X-Received: by 10.202.7.193 with SMTP id 184mr8505462oih.132.1490039906416; Mon, 20 Mar 2017 12:58:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.187.8 with HTTP; Mon, 20 Mar 2017 12:58:05 -0700 (PDT) From: Jason Merrill Date: Mon, 20 Mar 2017 15:58:05 -0400 Message-ID: Subject: C++ PATCH for c++/80096, ICE with C++17 non-type auto To: gcc-patches List X-IsSubscribed: yes Normally tsubst substitutes into the TREE_TYPE of the argument before proceeding; that's wrong for an auto template parameter, which should just get the appropriate type from its non-type argument. Tested x86_64-pc-linux-gnu, applying to trunk. commit 63a21767d094ac5c7b1a1ca0cd3d0366411c1a77 Author: Jason Merrill Date: Mon Mar 20 15:36:49 2017 -0400 PR c++/80096 - ICE with C++17 non-type auto. * pt.c (tsubst): Delay tsubst of type of template non-type parameter. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f180710..a4bf890 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13388,6 +13388,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (type && code != TYPENAME_TYPE && code != TEMPLATE_TYPE_PARM + && code != TEMPLATE_PARM_INDEX && code != IDENTIFIER_NODE && code != FUNCTION_TYPE && code != METHOD_TYPE) @@ -13690,6 +13691,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) break; case TEMPLATE_PARM_INDEX: + /* OK, now substitute the type of the non-type parameter. We + couldn't do it earlier because it might be an auto parameter, + and we wouldn't need to if we had an argument. */ + type = tsubst (type, args, complain, in_decl); r = reduce_template_parm_level (t, type, levels, args, complain); break; diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C new file mode 100644 index 0000000..381ed51 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C @@ -0,0 +1,9 @@ +// PR c++/80096 +// { dg-options -std=c++1z } + +template struct A +{ + template struct B {}; +}; + +A<0> a;