From patchwork Sun Sep 15 15:48:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1985899 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=UOEEgavz; 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 4X6CCW37lhz1y1T for ; Mon, 16 Sep 2024 01:49:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 308023858428 for ; Sun, 15 Sep 2024 15:49:25 +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 ESMTP id A41503858D20 for ; Sun, 15 Sep 2024 15:49:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A41503858D20 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 A41503858D20 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=1726415343; cv=none; b=wxK7oYGJ4rFiD88oKt2iHMjrWeYtguXuNUMJEnLQD/AS44ftDCsnv+iBn+8/fDl2JQEFe7iVn72o0rKwlpl0RYAm7MPMMf+As8CnPWoKZjFzt4yjSqQg+uW1fywZlGAdEYuXx/Uldxes5ekSn9WQ+ZQ3OKiE1QMZUsX2NHJwZ68= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726415343; c=relaxed/simple; bh=oG+bGqAFE/OIPeraqgZGced5x5Eh1Ae3sRE3zUpgqCo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SaTkYZh1WK4Ef78SuZ/3+rLyDiAz53pLHixy6MVg05tRIcuVQlvUTD0wqufSYS7VadIfdWno1gO0lfbm+1q4/Q9XP3zDedV01/MqSE3NgCmNMXz+wDIDNaaoKuaq2+0EnBiRDnPpKgfE1Ya0xrF26T4v6Oufzs7vyxdmV7QkqxA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726415342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o82vwwUYlxxONjsWwYE8lvyIq/m7J8cSmSr4HE0qkQ8=; b=UOEEgavzpZme5HM9xMd6ghQYYVlCGXV1QSALg9zKkB+Veo4mghlJmdLQDep0acylBD8YGj YUafupYPnfsUxQIG+hbAZtMHaJrNCOsUX278w9PMIupcKGxlPzb4lcHfYornuEsuuFkUfo mVQ2alRiz5KOWPv7K+YgauTzV3fu/d0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-cOUH3yKFOdSNksZkQYBsHA-1; Sun, 15 Sep 2024 11:49:01 -0400 X-MC-Unique: cOUH3yKFOdSNksZkQYBsHA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42cb115566eso22828035e9.2 for ; Sun, 15 Sep 2024 08:49:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726415339; x=1727020139; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=o82vwwUYlxxONjsWwYE8lvyIq/m7J8cSmSr4HE0qkQ8=; b=Z7uRciQ5GTfFX5OxXrFQ9tbj0k0b1J9YrP70fCigbFq90VSj+i5EsSvp/L1IUDg/mm fTILBuYks7Id70/F8+ZtEJx6o/kG4k9xS6/4bvahBSoV4zBnSRezdF3moTJU72Q6s0tf 1sJL/A0IibuTn2CQRh6Qi8wA3+4baA5yPsOuR2of/iDqBXVVSH9V81k272zIPVIuVQUk P9lmVW9G0YurbcTrKG6mmaU9dVjnbuvcMs5dv18kYF4tfE0nN/dUz4Nggllw3J4nhTtE ldHEiNx2YRewAJ59s/nQOD/amDwbgf07oOZTpGGZrbXuuD+jjlvcbSxrHLP7eVcuq7to +tTQ== X-Gm-Message-State: AOJu0YwqejKDAShB2D0iy9+Q+JtHUxURhoxWJJC9D6wXN9Q77rqjFk+g hC4TlRhNkuO9YOIt+eQmPfkzIaiE50r5nJu8MwdGA3ahhb3CfTidktjggvK/BgnUhABCg8fIglo mEVvnKSrhG4q9j+9kWgP+o+pjuyVxVNWEKqa6pTFew0nOs0bkUDgUK/IMDvSBYFG7vd5jxkGntC UgTo50F0WIW620h1q9ZbspPowOsnWRzTFTnEkGlw== X-Received: by 2002:a05:600c:1c12:b0:42c:b5a6:69bd with SMTP id 5b1f17b1804b1-42d964e0027mr92409125e9.30.1726415339440; Sun, 15 Sep 2024 08:48:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi2ZutKzMrA+X3MH/41MqwM1jPvsafoyt/shE0h1BnrB8Ghdej1bQStWy93QqIS0Ea2hi16Q== X-Received: by 2002:a05:600c:1c12:b0:42c:b5a6:69bd with SMTP id 5b1f17b1804b1-42d964e0027mr92408885e9.30.1726415338730; Sun, 15 Sep 2024 08:48:58 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (90-183-52-11.rcq.o2.cz. [90.183.52.11]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42da22b8b49sm52376415e9.2.2024.09.15.08.48.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2024 08:48:58 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: conversion location Date: Sun, 15 Sep 2024 17:48:38 +0200 Message-ID: <20240915154856.463159-1-jason@redhat.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, 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 Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- It seems more useful for a conversion to have the location of the source expression rather than the enclosing expression, such as a call that might convert multiple arguments in different ways. As a result, in srcloc17.C the recorded location of 'e' when copy-initialized became that of the initializer rather than the variable, since the semantic was to convert the initializer (at its location) and then initialize the variable from the resulting prvalue. If we instead direct-initialize the variable, the location of the constructor call is that of the variable. gcc/cp/ChangeLog: * call.cc (convert_like_internal) [ck_user]: Use iloc_sentinel. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/srcloc17.C: Adjust initialization. --- gcc/cp/call.cc | 4 ++++ gcc/testsuite/g++.dg/cpp2a/srcloc17.C | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) base-commit: 2af87d98e66e57d51f36220de983eff44bae98c8 diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index d30f36d49ff..664088eed9c 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -8669,6 +8669,10 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, rvalue, but we know it's read. */ mark_exp_read (expr); + /* Give the conversion call the location of EXPR rather than the + location of the context that caused the conversion. */ + iloc_sentinel ils (loc); + /* Pass LOOKUP_NO_CONVERSION so rvalue/base handling knows not to allow any more UDCs. */ expr = build_over_call (cand, LOOKUP_NORMAL|LOOKUP_NO_CONVERSION, diff --git a/gcc/testsuite/g++.dg/cpp2a/srcloc17.C b/gcc/testsuite/g++.dg/cpp2a/srcloc17.C index a02ea487eef..4462038d588 100644 --- a/gcc/testsuite/g++.dg/cpp2a/srcloc17.C +++ b/gcc/testsuite/g++.dg/cpp2a/srcloc17.C @@ -90,7 +90,7 @@ bar () return false; } - S e = __LINE__; + S e (__LINE__); // ^ column 8 S f = 1.0; if (cmp (e.loc.file_name (), file1))