From patchwork Fri May 3 15:26:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1931079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FCwOF+lx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VWF6S0bPyz1ybC for ; Sat, 4 May 2024 01:27:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA4223845BE1 for ; Fri, 3 May 2024 15:27:23 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTPS id B43BE384AB58 for ; Fri, 3 May 2024 15:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B43BE384AB58 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B43BE384AB58 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714750024; cv=none; b=mfbg0vRO/p09zDgydKdUp4M0Y5hRH1J2sS3z3Acy9jbHFF8wnT89otxtFzBrM6oPbWSvT1o9Kmvuka99GfH95lYSFqCfrhRF+I4VqVRav2X7wCWlovs30rUG1AWna+LLUsWQ+F31zRQhvUvIXiXJJeLZxr92q/c0pKXMx8zzpFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714750024; c=relaxed/simple; bh=/W/dNNr9bl3/jhDdi/z07giT5mAe4RVkW3GNeJ8frgk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tKGgPUH+ThWvVrM5snqigIpy8zoKGYvKbhUKUX24EaO5r3S+xaLtP5i5ipAnqtl2qoTe+7bGiaYJWqMwnJoV0reDciBUbGe3ozxkEk+M3zd7DdUPczfeB7esgZtNXrDwxeGT3WkCf5UIbyw3KIMfpXY4UOB5vvu2Udf2apyfLys= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714750022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=46lwIqTLKl0WEoScjkIDC/q7cCZoBGn0BbMDfL8Ed3Y=; b=FCwOF+lxM2FbEpXwsSHXHLfbNBKFm0sH7KbBYe+ZAO81mWeI2MedTmxgKuptCFCcnRzDPo 3KKLEheCkJ77ObV9i3tkAEGb0fXBfkwN9Mp6Z26tcW5diRbOrCwMfN2INOkcNxkBudPY+x +UWB5lXC9lvDIGLgH5kdNOPf9OeY5nI= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-YEi_DhjhOHudrITMjMdD3Q-1; Fri, 03 May 2024 11:27:00 -0400 X-MC-Unique: YEi_DhjhOHudrITMjMdD3Q-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-78ee7776740so1238450085a.2 for ; Fri, 03 May 2024 08:27:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714750020; x=1715354820; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=46lwIqTLKl0WEoScjkIDC/q7cCZoBGn0BbMDfL8Ed3Y=; b=MSiaMbV9k0MkASTHUwkCdJh20CCVhgcOg1E9OTy5UUi7oF3CVWKVFISnRsOabSZuCc ojM4R4uzSOZQwDPa1Xk+yDgRd1uE/RsysXoFU44GT8YS6B2xJ0/nqXUfoAppYhs0xL8R mTm0UWmZWUDVmtfNwkgLZTICpzvZlG2GFdcYisCerUqk8Luikpy4kRkVw5pS0AbY7kvE cTLTJja296GC99qoZ7GE+kPR+gcgbWin+EYrBjT5e/VXsVZwxFIfy+T4Nuw84ij3nKO1 gp7qPEwl1IiNqNgMPpyYY3Tb2rvQc45Z2UVXI/yCVEB0vPc4B22PS9khT+WoEdQhxNDX Qneg== X-Gm-Message-State: AOJu0YxNpOQaLVshN8gQ/v8twa/0BVAyULZmCuR5cbIZprQonInaPoQM 7y8SjFir9U4vKnx6BNTns+kWmyKEpfXZJ61O/b4BC7T1jeuNXwpe1zWi8DlOn49KXb91Ti5smJ3 yTWEokA/lkhIz6Ukzi8ILZ+pR623sS4WiER4sYplmLhjsRytGAJhcDdyRG1/8Ud0+YtoALtrsFo 6QZ1V0lxm0F2qWtNurYNyx/SONIwv4J4SKTZ7C X-Received: by 2002:a05:620a:2108:b0:78d:58d2:b600 with SMTP id l8-20020a05620a210800b0078d58d2b600mr3000842qkl.42.1714750019582; Fri, 03 May 2024 08:26:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcNILhspsf2ijnfRPbbjiX/v6X+fN17842f+mCBWH7N/fb+bkkQBO/OW1jS10kOKswc90TUQ== X-Received: by 2002:a05:620a:2108:b0:78d:58d2:b600 with SMTP id l8-20020a05620a210800b0078d58d2b600mr3000806qkl.42.1714750019045; Fri, 03 May 2024 08:26:59 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id j29-20020a05620a001d00b00790e82f86e0sm1324059qki.41.2024.05.03.08.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 08:26:58 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: replace tf_norm with a local flag Date: Fri, 3 May 2024 11:26:56 -0400 Message-ID: <20240503152657.479854-1-ppalka@redhat.com> X-Mailer: git-send-email 2.45.0.31.gd4cc1ec35f MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.3 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- The tf_norm flag controlling whether to build diagnostic information during constraint normalization doesn't need to be a global tsubst flag, and is confusingly named. This patch replaces it with a boolean flag local to normalization. gcc/cp/ChangeLog: * constraint.cc (norm_info::norm_info): Take a boolean parameter instead of tsubst_flags_t. (norm_info::generate_diagnostics): Turn this predicate function into a data member. (normalize_logical_operation): Adjust after norm_info changes. (normalize_concept_check): Likewise. (normalize_atom): Likewise. (get_normalized_constraints_from_info): Likewise. (normalize_concept_definition): Likewise. (normalize_constraint_expression): Likewise. (normalize_placeholder_type_constraints): Likewise. (satisfy_nondeclaration_constraints): Likewise. * cp-tree.h (enum tsubst_flags): Remove tf_norm. --- gcc/cp/constraint.cc | 40 ++++++++++++++++++++-------------------- gcc/cp/cp-tree.h | 3 +-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 8a3b5d80ba7..3f0dab79bcd 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -622,33 +622,29 @@ parameter_mapping_equivalent_p (tree t1, tree t2) struct norm_info : subst_info { - explicit norm_info (tsubst_flags_t cmp) - : norm_info (NULL_TREE, cmp) + explicit norm_info (bool diag) + : norm_info (NULL_TREE, diag) {} /* Construct a top-level context for DECL. */ - norm_info (tree in_decl, tsubst_flags_t complain) - : subst_info (tf_warning_or_error | complain, in_decl) + norm_info (tree in_decl, bool diag) + : subst_info (tf_warning_or_error, in_decl), + generate_diagnostics (diag) { if (in_decl) { initial_parms = DECL_TEMPLATE_PARMS (in_decl); - if (generate_diagnostics ()) + if (generate_diagnostics) context = build_tree_list (NULL_TREE, in_decl); } else initial_parms = current_template_parms; } - bool generate_diagnostics() const - { - return complain & tf_norm; - } - void update_context(tree expr, tree args) { - if (generate_diagnostics ()) + if (generate_diagnostics) { tree map = build_parameter_mapping (expr, args, ctx_parms ()); context = tree_cons (map, expr, context); @@ -679,6 +675,10 @@ struct norm_info : subst_info template parameters of ORIG_DECL. */ tree initial_parms = NULL_TREE; + + /* Whether to build diagnostic information during normalization. */ + + bool generate_diagnostics; }; static tree normalize_expression (tree, tree, norm_info); @@ -693,7 +693,7 @@ normalize_logical_operation (tree t, tree args, tree_code c, norm_info info) tree t1 = normalize_expression (TREE_OPERAND (t, 1), args, info); /* Build a new info object for the constraint. */ - tree ci = info.generate_diagnostics() + tree ci = info.generate_diagnostics ? build_tree_list (t, info.context) : NULL_TREE; @@ -777,7 +777,7 @@ normalize_concept_check (tree check, tree args, norm_info info) if (!norm_cache) norm_cache = hash_table::create_ggc (31); norm_entry *entry = nullptr; - if (!info.generate_diagnostics ()) + if (!info.generate_diagnostics) { /* Cache the normal form of the substituted concept-id (when not diagnosing). */ @@ -831,7 +831,7 @@ normalize_atom (tree t, tree args, norm_info info) if (info.in_decl && concept_definition_p (info.in_decl)) ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P (atom) = true; - if (!info.generate_diagnostics ()) + if (!info.generate_diagnostics) { /* Cache the ATOMIC_CONSTRs that we return, so that sat_hasher::equal later can cheaply compare two atoms using just pointer equality. */ @@ -910,7 +910,7 @@ get_normalized_constraints_from_info (tree ci, tree in_decl, bool diag = false) /* Substitution errors during normalization are fatal. */ ++processing_template_decl; - norm_info info (in_decl, diag ? tf_norm : tf_none); + norm_info info (in_decl, diag); tree t = get_normalized_constraints (CI_ASSOCIATED_CONSTRAINTS (ci), info); --processing_template_decl; @@ -1012,7 +1012,7 @@ normalize_concept_definition (tree tmpl, bool diag) gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL); tree def = get_concept_definition (DECL_TEMPLATE_RESULT (tmpl)); ++processing_template_decl; - norm_info info (tmpl, diag ? tf_norm : tf_none); + norm_info info (tmpl, diag); tree norm = get_normalized_constraints (def, info); --processing_template_decl; @@ -1035,7 +1035,7 @@ normalize_constraint_expression (tree expr, norm_info info) if (!expr || expr == error_mark_node) return expr; - if (!info.generate_diagnostics ()) + if (!info.generate_diagnostics) if (tree *p = hash_map_safe_get (normalized_map, expr)) return *p; @@ -1043,7 +1043,7 @@ normalize_constraint_expression (tree expr, norm_info info) tree norm = get_normalized_constraints (expr, info); --processing_template_decl; - if (!info.generate_diagnostics ()) + if (!info.generate_diagnostics) hash_map_safe_put (normalized_map, expr, norm); return norm; @@ -3190,7 +3190,7 @@ normalize_placeholder_type_constraints (tree t, bool diag) ? TMPL_PARMS_DEPTH (initial_parms) + 1 : 1), make_tree_vec (0), initial_parms); - norm_info info (diag ? tf_norm : tf_none); + norm_info info (diag); info.initial_parms = initial_parms; return normalize_constraint_expression (constr, info); } @@ -3226,7 +3226,7 @@ satisfy_nondeclaration_constraints (tree t, tree args, sat_info info) } else if (TREE_CODE (t) == NESTED_REQ) { - norm_info ninfo (info.noisy () ? tf_norm : tf_none); + norm_info ninfo (info.noisy ()); /* The TREE_TYPE contains the set of template parameters that were in scope for this nested requirement; use them as the initial template parameters for normalization. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index bc8e22cc39f..d4e216e361e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5696,8 +5696,7 @@ enum tsubst_flags { declaration. */ tf_no_cleanup = 1 << 10, /* Do not build a cleanup (build_target_expr and friends) */ - tf_norm = 1 << 11, /* Build diagnostic information during - constraint normalization. */ + /* 1 << 11 is free to use. */ tf_tst_ok = 1 << 12, /* Allow a typename-specifier to name a template (C++17 or later). */ tf_dguide = 1 << 13, /* Building a deduction guide from a ctor. */