From patchwork Mon Dec 19 11:19:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 34479 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2341720wrn; Mon, 19 Dec 2022 03:58:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf7sxrsb5K8gzHv5gImfCtBhdvmMgBs4Ka3w2SyUMgdvE7R2ya+2RaTcpMpsTSbUWgqRTjGw X-Received: by 2002:a17:906:2881:b0:7ad:d835:e822 with SMTP id o1-20020a170906288100b007add835e822mr33769823ejd.42.1671451117990; Mon, 19 Dec 2022 03:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671451117; cv=none; d=google.com; s=arc-20160816; b=SpWQci/5QU4ImeArcY+hXVfNLzhwXp9OFyCtZCLqbO/jSAqlxpxqJZ3/6A9YZF+ZmT LBPjuPgbOjtTHWapKrDoTVBnNetX8d2k/7Px2LmbKZYseeka8FKmIVWBKamxCBXxxBU0 SiJtGyStqWfRXel5g01Wha6uGY1MQyUPf/IezhOWzI/p3VeW55wdQdcZKELUl1J0z3Rw TIAN7lI6fg3h6l1Q4Dfz4Bggdf1Dm94lG0OD/zhkELbBGrBP5Mo0jCV4lSr1em5kxiHp vflHoqcJNwEIqws7u8AEG+8wLGMh7AJ+VIlCXuZ5AiBPvGgkb3mpAFAC2dUSnWBtrc82 h5Zg== 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=RxL2kH9TvMYXhFnMwS4p+OFE2A8YUKxdtXdb681xlNI=; b=rGpdkHYQ6stUwuGxFqFncNwWbsbjyEgpOEjji9WGkddcYUXkELpEDq9dhHVBp7nfQ1 h4sLPJ3ZziwQWbCIh37/tEKK7Qv3wCkELM6bvclan956V+qw7G/xERmFGNmleorPmLHh 5UPP1XD2tzRffEs8uysq1N+i6PC37buzr6y80fiNGxJdEeStOiW/qDIQhWqBKSEO1SA9 0ceVCL0draaClBYYbSR3JkmXf6xM0bj/olXKan8QyNNldDMmcuwZV3HJbTQl+k1Ce/Zs iVxW8bcx3ntgqAz4nNIUDmdyk0lYa277hoZkxdmoBcZYd7+pxiCR3+uiTPThwY/Lb2OE iieg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=q8YTnjIz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id xe12-20020a170907318c00b00791994dfb9esi11080370ejb.491.2022.12.19.03.58.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 03:58:37 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=q8YTnjIz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 B1EA5383B687 for ; Mon, 19 Dec 2022 11:20:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1EA5383B687 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671448843; bh=RxL2kH9TvMYXhFnMwS4p+OFE2A8YUKxdtXdb681xlNI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=q8YTnjIz/X+ruSLTJsBhFVVzEZinvItW0lSZxfDyw7Yn4Fr36ObsRsYQWyf5BbeNN APbpKEl0gq8ALNyIFaDI7UZ9WniVpTd+KtL5k+LuTC/gdi7u9J/m5tyQkErpJO44Oj 8NTjd6kE36cbWdYGtkMzE/FNfBnAcHZZuBVL8xpM= 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 011BC38475A8 for ; Mon, 19 Dec 2022 11:19:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 011BC38475A8 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-34-JLNS2lEXObapLjp_KyxiPw-1; Mon, 19 Dec 2022 06:19:55 -0500 X-MC-Unique: JLNS2lEXObapLjp_KyxiPw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCBBC29AA2E9; Mon, 19 Dec 2022 11:19:54 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C6132166B26; Mon, 19 Dec 2022 11:19:54 +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 2BJBJqWv776776 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 12:19:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2BJBJphr776775; Mon, 19 Dec 2022 12:19:51 +0100 Date: Mon, 19 Dec 2022 12:19:51 +0100 To: Gaius Mulley Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] modula2: Don't treat % in Modula 2 messages specially Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 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?1752643527184545628?= X-GMAIL-MSGID: =?utf-8?q?1752643527184545628?= Hi! On top of the just posted patch, this patch makes sure that any % chars in message strings aren't treated as format chars. None of these functions take variable number of arguments, so for most of format specifiers there is nowhere to take arguments from, it is true that a couple of format specifiers don't take any arguments - %%, %m, %<, %>, %' - so it is actually possible to use them, but one needs to verify that no other are emitted and that what should be printed as % is really emitted as %%. If the FE does that, then please ignore this patch, otherwise I think it is safer to do this. Bootstrapped/regtested on x86_64-linux and i686-linux. 2022-12-19 Jakub Jelinek * gm2-gcc/m2linemap.cc (m2linemap_ErrorAt, m2linemap_ErrorAtf, m2linemap_WarningAtf, m2linemap_NoteAtf, m2linemap_internal_error): Call functions with "%s", message rather than just message, so that % chars in message aren't treated as format specifiers. Jakub --- gcc/m2/gm2-gcc/m2linemap.cc.jj 2022-12-18 22:23:08.825497256 +0100 +++ gcc/m2/gm2-gcc/m2linemap.cc 2022-12-18 22:24:13.104563212 +0100 @@ -177,7 +177,7 @@ EXTERN void m2linemap_ErrorAt (location_t location, char *message) { - error_at (location, message); + error_at (location, "%s", message); } /* m2linemap_ErrorAtf - wraps up an error message. */ @@ -198,7 +198,7 @@ m2linemap_ErrorAtf_1 (location_t locatio void m2linemap_ErrorAtf (location_t location, const char *message) { - m2linemap_ErrorAtf_1 (location, message); + m2linemap_ErrorAtf_1 (location, "%s", message); } /* m2linemap_WarningAtf - wraps up a warning message. */ @@ -219,7 +219,7 @@ m2linemap_WarningAtf_1 (location_t locat void m2linemap_WarningAtf (location_t location, const char *message) { - m2linemap_WarningAtf_1 (location, message); + m2linemap_WarningAtf_1 (location, "%s", message); } /* m2linemap_NoteAtf - wraps up a note message. */ @@ -240,7 +240,7 @@ m2linemap_NoteAtf_1 (location_t location void m2linemap_NoteAtf (location_t location, const char *message) { - m2linemap_NoteAtf_1 (location, message); + m2linemap_NoteAtf_1 (location, "%s", message); } /* m2linemap_internal_error - allow Modula-2 to use the GCC internal error. */ @@ -248,7 +248,7 @@ m2linemap_NoteAtf (location_t location, void m2linemap_internal_error (const char *message) { - internal_error (message); + internal_error ("%s", message); } /* UnknownLocation - return the predefined location representing an