From patchwork Mon May 2 22:05:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1625257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=pAkfYAep; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ksccq41yVz9s09 for ; Tue, 3 May 2022 08:06:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69CDA3857343 for ; Mon, 2 May 2022 22:06:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69CDA3857343 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651529190; bh=rBvsz3S7tCubkfDAMw5dvisOPR0evdQXyHDrMSy+DpU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pAkfYAepjTFWTMo7Kv6AJEeMxzosATuJQ3biEooggszhPd6cIg6qrfFdiByqgLpQ7 /kVir93xoOMkvvQOPC/jFIO9ocpb4JH69Nc/nsiUwkMu4DN2tomc5RWFduPrQsZbj+ VM0+MoUKk2LNm7KGIc+gjGCjU8Y3buJSnj6qyZws= 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 219273858C27 for ; Mon, 2 May 2022 22:05:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 219273858C27 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-ntMQ2AuAPWGY4MyzmLV7VQ-1; Mon, 02 May 2022 18:05:46 -0400 X-MC-Unique: ntMQ2AuAPWGY4MyzmLV7VQ-1 Received: by mail-qk1-f200.google.com with SMTP id s63-20020a372c42000000b0069ec0715d5eso11077475qkh.10 for ; Mon, 02 May 2022 15:05:46 -0700 (PDT) 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=rBvsz3S7tCubkfDAMw5dvisOPR0evdQXyHDrMSy+DpU=; b=cPxdtHRmHnXO8tYuuo8/q/QdSmrHJdX6j0CDiex6K8Ky0t3rt4wjgLnFpDgiU3OpU8 0T7KmNQ3Omyk+RTlFy8JOtHq9a3L4pFv+pIYxQYg7U/KttOxJT4EPY/vuhUP3GyN9bt9 ICsDiuah9aq6VVeo+aJJVM4vdKNwso1+OCpgXFsgkPNAEhOW75uJdtBV1U8mSvecKnH7 zd63rjLh0r5Xwy4+vDwWccBkW3uvsIoprnZVHvHvEA18mF3+NnUa0maGqDCbtBsm0ZWu gXUYqnp27FIV45Pmr5YYOfX9yZCTtqHMrtgZOjuvyuCy//BavS1ORp6F5q8fPD+0S4E/ DpTA== X-Gm-Message-State: AOAM531M0XnvtOXbwdURME5Hn6CwiB6oB9RDPo8bLxsUNY0U/O/Xy1MB Nwby9QDvl+WyuHbXo2UjJN9VibamZ5dmIgNMpAcvE92bj0/PS8cb9U1K6yqDVvrElIHT6cyg3xw OtSDvDuFc+Jy+TWmsG5Gef5J/A7CnbiL2hM0aN7cit8G+W3N9/+0XRYazMn9vUNeZdw== X-Received: by 2002:a0c:d7cd:0:b0:432:8df8:94e2 with SMTP id g13-20020a0cd7cd000000b004328df894e2mr11197726qvj.90.1651529145641; Mon, 02 May 2022 15:05:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf2JIu8jI9ITs9RTfx4tCOZ+bcKTAXCns7klILm0sunsp88aMncMvIgbaC1Kh7GpvT7ymUHg== X-Received: by 2002:a0c:d7cd:0:b0:432:8df8:94e2 with SMTP id g13-20020a0cd7cd000000b004328df894e2mr11197692qvj.90.1651529145219; Mon, 02 May 2022 15:05:45 -0700 (PDT) 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 n205-20020a3727d6000000b0069f8b039332sm5024728qkn.1.2022.05.02.15.05.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 15:05:44 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: improve template-id location Date: Mon, 2 May 2022 18:05:41 -0400 Message-Id: <20220502220541.1502504-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.4 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On PR102629 I noticed that we were giving the entire lambda as the location for this template-id. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * pt.cc (tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Copy location. (do_auto_deduction): Use expr location. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-pack-init7.C: Check column number. --- gcc/cp/pt.cc | 28 +++++++++++-------- .../g++.dg/cpp2a/lambda-pack-init7.C | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) base-commit: dcb4bd0789d13dd4d07428bff712d01d3ea71ebe diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 23fbd8245d4..3edee50924f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -20091,6 +20091,7 @@ tsubst_copy_and_build (tree t, object = NULL_TREE; tree tid = lookup_template_function (templ, targs); + protected_set_expr_location (tid, EXPR_LOCATION (t)); if (object) RETURN (build3 (COMPONENT_REF, TREE_TYPE (tid), @@ -30181,6 +30182,8 @@ do_auto_deduction (tree type, tree init, tree auto_node, /* Nothing we can do with this, even in deduction context. */ return type; + location_t loc = cp_expr_loc_or_input_loc (init); + /* [dcl.spec.auto]: Obtain P from T by replacing the occurrences of auto with either a new invented type template parameter U or, if the initializer is a braced-init-list (8.5.4), with @@ -30195,9 +30198,9 @@ do_auto_deduction (tree type, tree init, tree auto_node, { if (complain & tf_warning_or_error) { - if (permerror (input_location, "direct-list-initialization of " + if (permerror (loc, "direct-list-initialization of " "% requires exactly one element")) - inform (input_location, + inform (loc, "for deduction to %, use copy-" "list-initialization (i.e. add %<=%> before the %<{%>)"); } @@ -30288,9 +30291,10 @@ do_auto_deduction (tree type, tree init, tree auto_node, && (auto_node == DECL_SAVED_AUTO_RETURN_TYPE (current_function_decl)) && LAMBDA_FUNCTION_P (current_function_decl)) - error ("unable to deduce lambda return type from %qE", init); + error_at (loc, "unable to deduce lambda return type from %qE", + init); else - error ("unable to deduce %qT from %qE", type, init); + error_at (loc, "unable to deduce %qT from %qE", type, init); type_unification_real (tparms, targs, parms, &init, 1, 0, DEDUCE_CALL, NULL, /*explain_p=*/true); @@ -30362,23 +30366,23 @@ do_auto_deduction (tree type, tree init, tree auto_node, { case adc_unspecified: case adc_unify: - error("placeholder constraints not satisfied"); + error_at (loc, "placeholder constraints not satisfied"); break; case adc_variable_type: case adc_decomp_type: - error ("deduced initializer does not satisfy " - "placeholder constraints"); + error_at (loc, "deduced initializer does not satisfy " + "placeholder constraints"); break; case adc_return_type: - error ("deduced return type does not satisfy " - "placeholder constraints"); + error_at (loc, "deduced return type does not satisfy " + "placeholder constraints"); break; case adc_requirement: - error ("deduced expression type does not satisfy " - "placeholder constraints"); + error_at (loc, "deduced expression type does not satisfy " + "placeholder constraints"); break; } - diagnose_constraints (input_location, auto_node, full_targs); + diagnose_constraints (loc, auto_node, full_targs); } return error_mark_node; } diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C index f3c3899e97a..face7258c2e 100644 --- a/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C @@ -8,7 +8,7 @@ struct S {}; template void foo(Args&&... args) { - [...args = forward /*(args)*/] { // { dg-error "" } + [...args = forward /*(args)*/] { // { dg-error "14:" } [](auto...) { } (forward(args)...); }; }