From patchwork Thu Dec 3 17:01:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1410498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=JPYIwFZq; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cn2Dk3w3sz9sPB for ; Fri, 4 Dec 2020 04:01:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA976385783E; Thu, 3 Dec 2020 17:01:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by sourceware.org (Postfix) with ESMTPS id ECF12385780A for ; Thu, 3 Dec 2020 17:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ECF12385780A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qt1-x834.google.com with SMTP id o1so1837510qtp.5 for ; Thu, 03 Dec 2020 09:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=um2gMmSw/7337jhQAGkTofpq/4OEE5eEsZlu9osdrcI=; b=JPYIwFZqOe/awyUgaVrQ/Ng7dxadtu9e3VRzQjdWAbe6nj9wy6NMmEYqzPT4WyzDmc UtsAOScV7D4ZwmGgL78s/CXe+PILsqmDWHESVmdnR16+9HZBoPruAiV6yanhRABBUjud atzrfBPuXTHBHwjunHiauGp1MWjruiGIoTWGl5kXMwtwi419u1zsz/xXwH45Gmf0/03y uOZmg8TQBxnOntcDFN8eI6pIc7Q3goJ7ypEl91lqGRhXVcTEMSz51ld1wDT1i5Qdh9k5 U9YvvfzXHbjODMfRTnseJzEZQeU8IV0q/MPzi/kUbLfmLtIFl5yrfeJVu5L3gjI0xa/a xbTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=um2gMmSw/7337jhQAGkTofpq/4OEE5eEsZlu9osdrcI=; b=XuZEvKn0eVyw20UDy/gKcGbZwDCYp6CQfGLE0ArjDwFm32mcHZDDcM0BN5VW0V9YoU 6noaWOk2eJZkkeggTnlIA9NgvzxJoDaSL3ZkLdsIRK8YSjKdwF+rs9mf+ah+nIajU962 fxHYSRtBEH+1hrCkuIibOvghv1/p+L56gNcVCSkADTtBxKpwICBoasbDWKK4i0HGInjJ R9jrv8ZpoEig9qk63PNsRvS74whdQwztHnE0lqkqafSRb8L/Ylfy8SWAVHKmilw0wSM8 eCtlHVkEiGfX8sximaOpEQapw7JoXEtXnzRS5t2Z1FrtHXQlqxDf1ZIctuXszUVx9HYf 0bbQ== X-Gm-Message-State: AOAM533FiPh5us31hCDR26jWWwG+7/2+uhW3EMgNQlpOoWnp9Dnwk1Cv ZIIhcCjZ25JjBejW8PbDZg0= X-Google-Smtp-Source: ABdhPJwBrNhnxqRgW5fvcy54OcYQXjAnisvEpc0kcZR+zDANat/AZf4LveQ4bj7C0kXp6lWUH+xT3w== X-Received: by 2002:ac8:488d:: with SMTP id i13mr4233194qtq.148.1607014894215; Thu, 03 Dec 2020 09:01:34 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:fd8c:7733:5cca:4143? ([2620:10d:c091:480::1:6627]) by smtp.googlemail.com with ESMTPSA id b64sm1889603qkg.19.2020.12.03.09.01.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2020 09:01:33 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: templatey type creation Message-ID: <745da3af-3ab5-8ea8-b3ee-8f7642f228ff@acm.org> Date: Thu, 3 Dec 2020 12:01:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch makes a couple of type-creation routines available to modules. That needs to create unbound template parms, and canonical template parms. gcc/cp/ * cp-tree.h (make_unbound_class_template_raw): Declare. (canonical_type_parameter): Declare. * decl.c (make_unbound_class_template_raw): Break out of ... (make_unboud_class_template): ... here. Call it. * pt.c (canonical_type_parameter): Externalize. Refactor & set structural_equality for type parms. pushing to trunk diff --git i/gcc/cp/cp-tree.h w/gcc/cp/cp-tree.h index de905dcf37c..69f8ed56e62 100644 --- i/gcc/cp/cp-tree.h +++ w/gcc/cp/cp-tree.h @@ -6542,6 +6542,7 @@ extern bool check_omp_return (void); extern tree make_typename_type (tree, tree, enum tag_types, tsubst_flags_t); extern tree build_typename_type (tree, tree, tree, tag_types); extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t); +extern tree make_unbound_class_template_raw (tree, tree, tree); extern tree build_library_fn_ptr (const char *, tree, int); extern tree build_cp_library_fn_ptr (const char *, tree, int); extern tree push_library_fn (tree, tree, tree, int); @@ -6880,6 +6881,7 @@ extern void maybe_show_extern_c_location (void); extern bool literal_integer_zerop (const_tree); /* in pt.c */ +extern tree canonical_type_parameter (tree); extern void push_access_scope (tree); extern void pop_access_scope (tree); extern bool check_template_shadow (tree); diff --git i/gcc/cp/decl.c w/gcc/cp/decl.c index 0cf84a0750c..a28e7924869 100644 --- i/gcc/cp/decl.c +++ w/gcc/cp/decl.c @@ -4132,6 +4132,14 @@ make_unbound_class_template (tree context, tree name, tree parm_list, return tmpl; } + return make_unbound_class_template_raw (context, name, parm_list); +} + +/* Build an UNBOUND_CLASS_TEMPLATE. */ + +tree +make_unbound_class_template_raw (tree context, tree name, tree parm_list) +{ /* Build the UNBOUND_CLASS_TEMPLATE. */ tree t = cxx_make_type (UNBOUND_CLASS_TEMPLATE); TYPE_CONTEXT (t) = FROB_CONTEXT (context); diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c index 66ac6473983..3ca28133d94 100644 --- i/gcc/cp/pt.c +++ w/gcc/cp/pt.c @@ -4432,7 +4432,7 @@ build_template_parm_index (int index, parameter. Returns the canonical type parameter, which may be TYPE if no such parameter existed. */ -static tree +tree canonical_type_parameter (tree type) { int idx = TEMPLATE_TYPE_IDX (type); @@ -13212,19 +13212,24 @@ tsubst_argument_pack (tree orig_arg, tree args, tsubst_flags_t complain, tree in_decl) { /* Substitute into each of the arguments. */ - tree new_arg = TYPE_P (orig_arg) - ? cxx_make_type (TREE_CODE (orig_arg)) - : make_node (TREE_CODE (orig_arg)); - tree pack_args = tsubst_template_args (ARGUMENT_PACK_ARGS (orig_arg), args, complain, in_decl); - if (pack_args == error_mark_node) - new_arg = error_mark_node; - else - SET_ARGUMENT_PACK_ARGS (new_arg, pack_args); + tree new_arg = error_mark_node; + if (pack_args != error_mark_node) + { + if (TYPE_P (orig_arg)) + { + new_arg = cxx_make_type (TREE_CODE (orig_arg)); + SET_TYPE_STRUCTURAL_EQUALITY (new_arg); + } + else + { + new_arg = make_node (TREE_CODE (orig_arg)); + TREE_CONSTANT (new_arg) = TREE_CONSTANT (orig_arg); + } - if (TREE_CODE (new_arg) == NONTYPE_ARGUMENT_PACK) - TREE_CONSTANT (new_arg) = TREE_CONSTANT (orig_arg); + SET_ARGUMENT_PACK_ARGS (new_arg, pack_args); + } return new_arg; }