From patchwork Wed Feb 9 15:39:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 50956 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9EA40385840B for ; Wed, 9 Feb 2022 15:40:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EA40385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644421238; bh=DLC4m6dK97ME9cd8wlXkqyT400NqKu9uytavyw8aZEI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oJUCdQ2FUVk3ImSLFYXA5kl+iXMroNG8pmiE7ZcIUcfcSFNUuC5R2giCqZPcED3Fg nFHqDGoop2JeY9kjBUSg9ByNGURXu65lTwz/5E43Rn14zJwGrcKS/UrJdhANYdR3sh znYREc1qJ5XS91lCUGNoHNkFilnp9fPsOf11IgjM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E0FD2385840B for ; Wed, 9 Feb 2022 15:40:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0FD2385840B Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-I1yYNbOoMsqCjOjQurp4rw-1; Wed, 09 Feb 2022 10:39:59 -0500 X-MC-Unique: I1yYNbOoMsqCjOjQurp4rw-1 Received: by mail-qt1-f199.google.com with SMTP id a9-20020aed2789000000b002d78436cc47so1997143qtd.12 for ; Wed, 09 Feb 2022 07:39:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DLC4m6dK97ME9cd8wlXkqyT400NqKu9uytavyw8aZEI=; b=d8nkv4I56MC1YVxLkMrEp36rusRPeJ3lNtGDpko5vuZy1xayDtpd1AtMjQ/r0Z+0iZ qD3V/5+jCaez/SnxYm+oAUjbD4gUAsmLxYDncEQ+Djxa37FsU6nASH0tNkiMek+WJ6Lr KjkBnaDy4c21xw6prJlcdJh7P/T/bj2GdogDbsz9VTNDC0hd8dBgxk15Df8yaDd/xK8g rJZtR5QNGM9YA9SpoMxvKwNyjXM0RWfN2eyjtokQBUhPxHABnzEYJPoFrYiiiZ9s6nPq 2zVpjPXJlCGWCo2KoOaoK/ZUTJuo2qjGTwqWEUt/CADgop5Iknw/ngZEA3QfkJEc91Bq q+3A== X-Gm-Message-State: AOAM530SVHfsJn3G5fNH1JYQsWPTDBUdi421t4q1D9FWLRXMifTHwNMO uMSAp96X1vVke1Y/pYqZxsUAFUOKA1kk+gqt+ADASuM+yyJ4QeHg2XvtX0HbN54xogKXxqlqrgu aEkUeXXVHEFZvHw9GFBtRB1ZNhzcHbruGMODEz8HX976c4tUXEa67PBdN0tkDd++7Qw== X-Received: by 2002:a05:6214:e84:: with SMTP id hf4mr1951225qvb.12.1644421198813; Wed, 09 Feb 2022 07:39:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwszGdad9zSY7tejmK1ckbB6zYHEHXnzmmIWFztu4itUWIbx56zRk66EmPwRKa/rAlw5jN1yA== X-Received: by 2002:a05:6214:e84:: with SMTP id hf4mr1951193qvb.12.1644421198308; Wed, 09 Feb 2022 07:39:58 -0800 (PST) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id bl34sm6292113qkb.15.2022.02.09.07.39.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 07:39:57 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: modules and explicit(bool) [PR103752] Date: Wed, 9 Feb 2022 10:39:55 -0500 Message-Id: <20220209153955.1199946-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" We weren't streaming a C++20 dependent explicit-specifier. gcc/cp/ChangeLog: * module.cc (trees_out::core_vals): Stream explicit specifier. (trees_in::core_vals): Likewise. * pt.cc (store_explicit_specifier): No longer static. (tsubst_function_decl): Clear DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P. * cp-tree.h (lookup_explicit_specifier): Declare. gcc/testsuite/ChangeLog: * g++.dg/modules/explicit-bool-1_b.C: New test. * g++.dg/modules/explicit-bool-1_a.H: New test. --- gcc/cp/cp-tree.h | 1 + gcc/cp/module.cc | 10 +++++++++ gcc/cp/pt.cc | 10 +++++++-- .../g++.dg/modules/explicit-bool-1_b.C | 6 +++++ .../g++.dg/modules/explicit-bool-1_a.H | 22 +++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H base-commit: d80f2248c5962318c77624a0eab05b81c59add1b diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f09055e4852..f253b32c3f2 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7420,6 +7420,7 @@ extern bool copy_guide_p (const_tree); extern bool template_guide_p (const_tree); extern bool builtin_guide_p (const_tree); extern void store_explicit_specifier (tree, tree); +extern tree lookup_explicit_specifier (tree); extern void walk_specializations (bool, void (*)(bool, spec_entry *, void *), diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 81ceef92df3..3cf0af10bc0 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -6034,6 +6034,9 @@ trees_out::core_vals (tree t) WT (t->function_decl.function_specific_target); WT (t->function_decl.function_specific_optimization); WT (t->function_decl.vindex); + + if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t)) + WT (lookup_explicit_specifier (t)); break; case USING_DECL: @@ -6531,6 +6534,13 @@ trees_in::core_vals (tree t) RT (t->function_decl.function_specific_target); RT (t->function_decl.function_specific_optimization); RT (t->function_decl.vindex); + + if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t)) + { + tree spec; + RT (spec); + store_explicit_specifier (t, spec); + } } break; diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 862f337886c..5c995da62c6 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13870,7 +13870,7 @@ store_explicit_specifier (tree v, tree t) /* Lookup an element in EXPLICIT_SPECIFIER_MAP. */ -static tree +tree lookup_explicit_specifier (tree v) { return *explicit_specifier_map->get (v); @@ -14103,7 +14103,13 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, /*function_p=*/false, /*i_c_e_p=*/true); spec = build_explicit_specifier (spec, complain); - DECL_NONCONVERTING_P (r) = (spec == boolean_true_node); + if (instantiation_dependent_expression_p (spec)) + store_explicit_specifier (r, spec); + else + { + DECL_NONCONVERTING_P (r) = (spec == boolean_true_node); + DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (r) = false; + } } /* OpenMP UDRs have the only argument a reference to the declared diff --git a/gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C b/gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C new file mode 100644 index 00000000000..27bfdee1a65 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C @@ -0,0 +1,6 @@ +// { dg-additional-options -fmodules-ts } +// { dg-require-effective-target c++20 } + +export module x; +import "explicit-bool-1_a.H"; +pair environment; diff --git a/gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H b/gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H new file mode 100644 index 00000000000..fa14de1137d --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H @@ -0,0 +1,22 @@ +// { dg-additional-options -fmodule-header } +// { dg-require-effective-target c++20 } + +template +struct pair +{ + constexpr + explicit(__is_same(_T1, _T2)) + pair() + { } + + _T1 first; + _T2 second; +}; + +struct string +{ + string() { } + string(const char* s) : s(s) { } + + const char* s = ""; +};