From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 40C073858C30 for ; Wed, 18 Oct 2023 17:45:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40C073858C30 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 40C073858C30 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697651143; cv=none; b=EzAy0G4kiK/CzERJlKaCSuIk1J/jQL5lemhODZwuy8YdRiyQaAjTEwugGnaw4E52bTHCNx7738nb5iVUIaRd/tesisS1gw+7quszvrZcA7yam1RQdeQlm6mQ0EX1dpIBIs9hfJ74x6HypIjQYGVSF39TSEpxOuX7q1C+aKFPbUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697651143; c=relaxed/simple; bh=48vW2s8mcPWVuQvWq7cJg+6QMhxAirsHDsZOtJhSvWc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=VNvoOsqvm0zMTK93p+jN2zqRVFER2v+UlOYHZDNQxa8XgBpW6ABJvkYWbICQjhZ/+yrKNbkva1MAO67qc/tHXjq0CRmP7rU8bBsO5AalJAVyfS9bHH5Evj/zMs5Vfz/2bYqxmP6rg0eIFA6GKplOPAs5DVrLLQWhk+XDhPRGh48= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697651141; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=2p4YX+5vBvDQJhb4N1J1JGlEBz75f8mlnmpM4ra5Ekg=; b=J1B/zr8K5rSYMb+8SuTo4gYyt3uwd7w/wkfP3v6MscOOpojy344Gcx4oPGP/eAekIdiGQP hKYSxUAWbByx7VIBXno4yfrTnA1XRVVCpzaW/j5PjWS+aZZEhH8TF0ELkpVbfMh6isJ071 Mj65KaIINcJXQi28K3XGXncu8zQRKg0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-gPBC26tiNf2Jtk_gnkCQ9g-1; Wed, 18 Oct 2023 13:45:38 -0400 X-MC-Unique: gPBC26tiNf2Jtk_gnkCQ9g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68AE41C11702; Wed, 18 Oct 2023 17:45:38 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AD4F1C060B0; Wed, 18 Oct 2023 17:45:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 39IHjZYK3720212 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 18 Oct 2023 19:45:36 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 39IHjYFm3720211; Wed, 18 Oct 2023 19:45:34 +0200 Date: Wed, 18 Oct 2023 19:45:34 +0200 From: Jakub Jelinek To: waffl3x Cc: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH v3 1/2] c++: Initial support for P0847R7 (Deducing This) [PR102609] Message-ID: Reply-To: Jakub Jelinek References: <9evl-z9cAecBNAGVh82igdeO_HCFYbASO5fS0ngotJBqdpab09FTYaMiAjlZUliISedO0mV66BldzWQtylI4Dax0yC2gdKWuM55xDaG6RQM=@protonmail.com> <09e57c81-5231-16e8-6e57-18c37663c325@redhat.com> <2024d9f2-7560-eb9e-e9d9-de8769a06a8b@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: On Wed, Oct 18, 2023 at 05:28:10PM +0000, waffl3x wrote: > I've seen plenty of these G_ or _ macros on strings around like in > grokfndecl for these errors. > > G_("static member function %qD cannot have cv-qualifier") > G_("non-member function %qD cannot have cv-qualifier") > > G_("static member function %qD cannot have ref-qualifier") > G_("non-member function %qD cannot have ref-qualifier") > > I have been able to figure out it relates to translation, but not > exactly what the protocol around them is. I think in my original patch > I had refactored this code a bunch, I figured adding a 3rd case to it > justifies a refactor. I think I forgot to add those changes to the > original patch, either that or I undid it or moved it somewhere else. > Anyway, the point is, coming back to it now to re-add those diagnostics > I realized I probably shouldn't have changed those strings. > > I also have been wondering whether I should be putting macros on any > strings I add, it seemed like there might have been a macro for text > that needs translation. Is this something I should be doing? There are different kinds of format strings in GCC, the most common are the gcc-internal-format strings. If you call a function which is expected to take such translatable format string (in particular a function which takes a gmsgid named argument like error, error_at, pedwarn, warning_at, ...) and pass a string literal to that function, nothing needs to be marked in a special way, both gcc/po/exgettext is able to collect such literals into gcc/po/gcc.pot for translations and the function is supposed to use gettext etc. to translate it - e.g. see diagnostic_set_info using _(gmsgid) for that. But, if there is e.g. a temporary pointer var which points to format strings and only that is eventually passed to the diagnostic functions, gcc/po/exgettext won't be able to collect such literals, which is where the G_() macro comes into play and one marks the string as gcc-internal-format with it; the translation is still handled by the diagnostic function at runtime. The N_() macro is similar but for c-format strings instead. The _() macro both collects for translations if it is used with string literal, and expands to gettext call to translate it at runtime, which is something that should be avoided if something translates it again. And another i18n rule is that one shouldn't try to construct diagnostic messages from parts of english sentences, it is fine to fill in with %s/%qs etc. language keywords etc. but otherwise the format string should contain the whole diagnostic line, so that translators can reorder the words etc. Jakub