From patchwork Tue Nov 24 12:30:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Burn X-Patchwork-Id: 548041 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 62CE214030F for ; Tue, 24 Nov 2015 23:30:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=EWniIH+n; 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:date:message-id:subject:from:to:content-type; q= dns; s=default; b=L0PLCBeAchltvp4JFsWO01zTjZCBww9C974qEiz3lvMzdu SvutWZBsSItFNAXiigk6lh45vbPn36jimhCzoJwglx/a7UxWfypruk6T7tZxtU2A ZlGNi9bPl+7phSXOrOeTWME0lDa+gPencVqFE9WdFp/0Rswzo74CrfrtgBYsc= 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:date:message-id:subject:from:to:content-type; s= default; bh=dt5lfeeB4G76FCUB4aE8T5BH4YQ=; b=EWniIH+nRW8ThHYp6YWr o2O/XkT+mySgxiTkGoMHQ6cDkZacv8JMdU09AKjI3BdCsmx5XyPaFRunUkO43B+V bqmnftcDd83LDmqxYGAjnzDKmsWs75Q8Ki0MiW5XR5sZmVd2gcZlEC6liu+wxfU7 3uWt4cxndHDKDRonYQk2LdE= Received: (qmail 128654 invoked by alias); 24 Nov 2015 12:30:45 -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 128617 invoked by uid 89); 24 Nov 2015 12:30:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-oi0-f51.google.com Received: from mail-oi0-f51.google.com (HELO mail-oi0-f51.google.com) (209.85.218.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 24 Nov 2015 12:30:39 +0000 Received: by oige206 with SMTP id e206so8626781oig.2 for ; Tue, 24 Nov 2015 04:30:37 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.202.74.69 with SMTP id x66mr19106509oia.96.1448368237555; Tue, 24 Nov 2015 04:30:37 -0800 (PST) Received: by 10.202.79.80 with HTTP; Tue, 24 Nov 2015 04:30:37 -0800 (PST) Date: Tue, 24 Nov 2015 07:30:37 -0500 Message-ID: Subject: [C++ PATCH] Fix same canonical type node ICE for constrained functions (PR c++/68434) From: Ryan Burn To: gcc-patches@gcc.gnu.org, Jason Merrill X-IsSubscribed: yes This patch rearranges the step in tsubst where a type's PLACEHOLDER_TYPE_CONSTRAINTS are set so that it happens before calling the function canonical_type_parameter. canonical_type_parameter makes comparisons between types stored in the canonical_template_parms global variable. One of the steps in comparing types (equivalent_placeholder_constraints) references the PLACEHOLDER_TYPE_CONSTRAINTS on types. If constraints aren't set at this point, types with different PLACEHOLDER_TYPE_CONSTRAINTS can compare equal and receive the same TYPE_CANONICAL parameter. Bootstrapped and regression tested on x86_64-linux 2015-11-19 Ryan Burn PR c++/68434 * pt.c (tsubst): Set PLACEHOLDER_TYPE_CONSTRAINTS before calling canonical_type_parameter. * g++.dg/concepts/pr68434.C: New test Index: gcc/cp/pt.c =================================================================== --- gcc/cp/pt.c (revision 230777) +++ gcc/cp/pt.c (working copy) @@ -12977,6 +12977,12 @@ TYPE_POINTER_TO (r) = NULL_TREE; TYPE_REFERENCE_TO (r) = NULL_TREE; + /* Propagate constraints on placeholders. */ + if (TREE_CODE (t) == TEMPLATE_TYPE_PARM) + if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (t)) + PLACEHOLDER_TYPE_CONSTRAINTS (r) + = tsubst_constraint (constr, args, complain, in_decl); + if (TREE_CODE (r) == TEMPLATE_TEMPLATE_PARM) /* We have reduced the level of the template template parameter, but not the levels of its @@ -12991,12 +12997,6 @@ else TYPE_CANONICAL (r) = canonical_type_parameter (r); - /* Propagate constraints on placeholders. */ - if (TREE_CODE (t) == TEMPLATE_TYPE_PARM) - if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (t)) - PLACEHOLDER_TYPE_CONSTRAINTS (r) - = tsubst_constraint (constr, args, complain, in_decl); - if (code == BOUND_TEMPLATE_TEMPLATE_PARM) { tree argvec = tsubst (TYPE_TI_ARGS (t), args, Index: gcc/testsuite/g++.dg/concepts/pr68434.C =================================================================== --- gcc/testsuite/g++.dg/concepts/pr68434.C (revision 0) +++ gcc/testsuite/g++.dg/concepts/pr68434.C (working copy) @@ -0,0 +1,21 @@ +// { dg-options "-std=c++1z" } + +template +concept bool C1 () { + return true; +} + +template +concept bool C2 () { + return true; +} + +template +concept bool C3 () { + return requires (Expr expr) { + {expr}->C1; + {expr}->C2; + }; +} + +auto f (C3);