From patchwork Tue Mar 28 15:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 76157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2316956vqo; Tue, 28 Mar 2023 08:45:30 -0700 (PDT) X-Google-Smtp-Source: AKy350YTf7mLXU97lPM2En6hoS2AlxDlg9QSsn0+qgKbcrQVYlWNObYst8OpzhHdiRa44wPa+Rbg X-Received: by 2002:a05:6402:415:b0:500:46f2:e7db with SMTP id q21-20020a056402041500b0050046f2e7dbmr16463435edv.15.1680018329999; Tue, 28 Mar 2023 08:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018329; cv=none; d=google.com; s=arc-20160816; b=ntpYCteR/iH9MTr3IAd8Vh7jORaPoH/oyIwPowov6Mz4p40zV1xJ4OmCLabtlKqp9Y Yb7Zi/MXRTD09EuamF6EfYFzcW7SaR2ISkBbgWN07ZuQPXNBhu3zTEaB86yxGrEeTloR PG7mQBOlMfOJzOrI4fJGWnqUlAb0MG3cTV9rfYfP9VNP0AcqaV6IbNh6OcsdfXAawAf0 2Dts2tVBvEbL/RMG/YibHL4Nl9MqyrrmnKagXqyfLmcruIDBz7lrb7FA5Ei7I0OYSOKi xwUAhRy8ogk/m9AaxMpCgw5mWXr78OQNQ+8XuWmNMBpuawvbRNS6jvDCtmS5Rj9v5W6G +2mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=cBjfzIlP4CuZpMjUj1IUfTJbFcfeX6UyWd9/UqmUQGI=; b=aD6luZiaYGNxlmsGqticJAS+mkS4IhUKUXa5SZhfOJ5bKid2ahQ0bE4AMKJd1/Yrhr jRF+vqwdwNIDOq9forldpog9UKWrljWLS3O3Dxu51WDBB3FPJ1vPs60HVOPamo0nJZ0h tRXvhvZnio/wYJGiR113HbK+vuzb8+Q/ug3QS3YnUOe4vUN8+ONCpJHdyQPH7BheJ+yD q0aVNtZ6uBOX8rUG1fBaEWy8lorcfdx/zCTM7ZyE4F/C4+eXNmWUIBIcmoiCwR0woVrt R9us0mYHyF3UAJTmt1fTi3RRAoHTsL2CcB0ns+Loedep6UzvzJnT2PRGQkxQSmlwcDV5 3FBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dG7AqHOs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e9-20020a056402104900b004ad06322427si15586513edu.9.2023.03.28.08.45.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 08:45:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dG7AqHOs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEB0B3858296 for ; Tue, 28 Mar 2023 15:45:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEB0B3858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680018328; bh=cBjfzIlP4CuZpMjUj1IUfTJbFcfeX6UyWd9/UqmUQGI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=dG7AqHOsUWhvM5858jESMMoSBCgNExBHj7g4JPm/LU8KLH9/ljr6YSUVPuuFf7A68 C8umHhXphbUpkMgEzM/7cB54gqs9mGC5AOoFD9S7XkE2ViCXxZuZFU3LaQSBKbDCi7 bkUOE1+LNC3NJj6PH9AE3FWysq7mxn301PBUslV0= 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 A10D63858D39 for ; Tue, 28 Mar 2023 15:44:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A10D63858D39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-218-a_C-lL9yOi2GL9iVirus_A-1; Tue, 28 Mar 2023 11:44:40 -0400 X-MC-Unique: a_C-lL9yOi2GL9iVirus_A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3432E85A588 for ; Tue, 28 Mar 2023 15:44:39 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB8751121330; Tue, 28 Mar 2023 15:44: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 32SFiax51449177 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 17:44:36 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32SFiajj1449176; Tue, 28 Mar 2023 17:44:36 +0200 Date: Tue, 28 Mar 2023 17:44:35 +0200 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Allow translations of check_postcondition_result messages [PR109309] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.3 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_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761626900309548912?= X-GMAIL-MSGID: =?utf-8?q?1761626900309548912?= Hi! As mentioned in the PR, constructing a message from two parts by concatenating them prevents translations, unless one of the parts is a keyword which should be never translated. The following patch fixes that, ok for trunk? 2023-03-28 Jakub Jelinek PR c++/109309 * contracts.cc: Include intl.h. (check_postcondition_result): Don't form diagnostics from two halves of an english message to allow translations. Jakub --- gcc/cp/contracts.cc.jj 2023-01-16 11:52:16.063734359 +0100 +++ gcc/cp/contracts.cc 2023-03-28 17:33:42.165326812 +0200 @@ -161,6 +161,7 @@ along with GCC; see the file COPYING3. #include "tree-iterator.h" #include "print-tree.h" #include "stor-layout.h" +#include "intl.h" const int max_custom_roles = 32; static contract_role contract_build_roles[max_custom_roles] = { @@ -636,17 +637,15 @@ bool check_postcondition_result (tree decl, tree type, location_t loc) { if (VOID_TYPE_P (type)) - { - const char* what; - if (DECL_CONSTRUCTOR_P (decl)) - what = "constructor"; - else if (DECL_DESTRUCTOR_P (decl)) - what = "destructor"; - else - what = "function"; - error_at (loc, "%s does not return a value to test", what); - return false; - } + { + error_at (loc, + DECL_CONSTRUCTOR_P (decl) + ? G_("constructor does not return a value to test") + : DECL_DESTRUCTOR_P (decl) + ? G_("destructor does not return a value to test") + : G_("function does not return a value to test")); + return false; + } return true; }