From patchwork Mon Jun 18 18:14:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 931129 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-479958-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="SUCxoomG"; 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 418fR138rbz9ryk for ; Tue, 19 Jun 2018 04:15:40 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=h5WhUpcv+/HgJuO7jpjAeF30jTDP8//33u33a33KIYXEgz s9U5Yw64Lv1HVSc1PkwErrjYp1NK+OOZynV6yd3cQPJsFd5+3RZn2sdQ81x1yApY NAL0DCSxTG0qDLhl9YnsMMiR6o08dzqXVzBfgzN6U5Y7Y+IpkoMateZdkXVjg= 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=qRidbPe5juMwdNF2tAmj8SoIYt4=; b=SUCxoomGCA0VDRKp4GJG biaBUspy7Ly2dMt7xWneBOqez+jGjReQ8kabZmkuvpk6MFxuyxYyo/O/Uu3r3Rpt J6Ex1ZiTq7avb14kXPnwivYsW9b0HWDvEXmB6jOv7YO2z9REsRd07B3xx8R/ywYW b7wZSvmSN4qcb/alsiub8nY= Received: (qmail 118235 invoked by alias); 18 Jun 2018 18:15:32 -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 118107 invoked by uid 89); 18 Jun 2018 18:15:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy= X-HELO: mail-oi0-f43.google.com Received: from mail-oi0-f43.google.com (HELO mail-oi0-f43.google.com) (209.85.218.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Jun 2018 18:15:04 +0000 Received: by mail-oi0-f43.google.com with SMTP id t22-v6so15713575oih.6 for ; Mon, 18 Jun 2018 11:15:04 -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=a+FhOPvMRTv6/pVzC6nOHddqETwnmwnQkb2xTiNVZGI=; b=Bu03r/YB14yaxQEkowDzFyYgVSthhjYzFS+DOnvcFfEpePtQyrzNZhQLuoyHhbWzVL wEfow69FHwwBHffbRv8GqNexIz1qud/xrQQ0tpYlHqZb5kIjebSvIsBCWhHHVoKZfayR HCda2fleUQxEWpE5X4gN/qAxWnl2wzKXDy91n/oYrWj6BgXZb8eoU60Qq6eL66synY3k lUwgzIjHsfn5MxgOJogTymG9Ln5L1LDAUF6T++FFspwfgcH4kyE2GE0vdW8Gb7Bq/End 64PtVbTemTr2tQPxA3QKj+4rQ86ydD3Bc9kiBGT+HeH34CRmVlMDD7/dGfaeX7hjS39B 27GQ== X-Gm-Message-State: APt69E082xnZ2e4xw9cAswPwpeqOiKau0wZuhS7DVzA42ZnGm/6iW130 jyDBLp1+uOJAGMThv3mGIk4zSdEYfQ1wtVBfKpmPzjDb X-Google-Smtp-Source: ADUXVKKYJ8n+e8+Bae4rnvwM7wzXp2GfOJ37K8jfB164VXMPZc5O/lbCnhOkGNsMKb52aLfWfby3T91Jfm2t4XrYlCk= X-Received: by 2002:aca:e882:: with SMTP id f124-v6mr6940313oih.352.1529345702340; Mon, 18 Jun 2018 11:15:02 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:dd0:0:0:0:0:0 with HTTP; Mon, 18 Jun 2018 11:14:41 -0700 (PDT) From: Jason Merrill Date: Mon, 18 Jun 2018 14:14:41 -0400 Message-ID: Subject: C++ PATCH for c++/86171, ICE with recursive alias instantiation To: gcc-patches List X-IsSubscribed: yes Here, instantiating B requires instantiating A, which requires instantiating B. Previously, that resulted in creating two separate TYPE_DECLS for B and trying to combine them in register_specialization. Better, I think, to check for this situation sooner. Tested x86_64-pc-linux-gnu, applying to trunk. commit f82ab957170984838b0bf4d9f7ef5d254eec28c3 Author: Jason Merrill Date: Mon Jun 18 11:53:39 2018 -0400 PR c++/86171 - ICE with recursive alias instantiation. * pt.c (tsubst_decl): Handle recursive alias instantiation. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4ee84b201e9..6e590d4d342 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13639,7 +13639,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) } /* Create a new node for the specialization we need. */ - r = copy_decl (t); if (type == NULL_TREE) { if (is_typedef_decl (t)) @@ -13664,7 +13663,16 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) sub_args = strip_innermost_template_args (args, extra); } type = tsubst (type, sub_args, complain, in_decl); + /* Substituting the type might have recursively instantiated this + same alias (c++/86171). */ + if (gen_tmpl && DECL_ALIAS_TEMPLATE_P (gen_tmpl) + && (spec = retrieve_specialization (gen_tmpl, argvec, hash))) + { + r = spec; + break; + } } + r = copy_decl (t); if (VAR_P (r)) { DECL_INITIALIZED_P (r) = 0; diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-65.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-65.C new file mode 100644 index 00000000000..e320f3eedd0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-65.C @@ -0,0 +1,10 @@ +// PR c++/86171 +// { dg-do compile { target c++11 } } + +template struct A; +template using B = typename A::X; +template struct A { + typedef int X; + typedef B U; +}; +B b;