From patchwork Mon Dec 4 10:42:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 81273 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8CDCF3857C58 for ; Mon, 4 Dec 2023 10:42:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id 799D2385AE42 for ; Mon, 4 Dec 2023 10:42:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 799D2385AE42 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cebitec.uni-bielefeld.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 799D2385AE42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.70.160.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701686541; cv=none; b=IemCt4wP8lAhqcXP/3LhKAoBUYMyzvclRHkz/cYYdV1LBPWp61G3ZKbULf7YKDm+pDpONSGLEUz95i3cTXmJN/KIIhJzRaIo8EZ7jBP2id8lR/xvAsmZKl3txH4ecRNar51VwWvqCo+SsmkjHjWoPZ09lRYgqTBtOVDYGjvS2aM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701686541; c=relaxed/simple; bh=W/d/T0OKhj1KT0T7UujZ4KoTrzercRBmRRp6qmWoS0A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gkh4FkcqCqQNE02oi+IQigI875Li8vcnWlUrpmklOogT3x3mWsQNZ9d3B7EIwx8iWELzzUpoAGyYRIQxabysjT/aHeioK4CDOEmvfq9WvAqJYuI7MzQm4+OS6QfRiCAU2bOTFgsq5+PNS+1zlI47gQqVBHON2Ex7FPLuK5n5CPc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 69B69CF96D for ; Mon, 4 Dec 2023 11:42:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= cebitec.uni-bielefeld.de; h=content-type:content-type :mime-version:user-agent:message-id:date:date:subject:subject :from:from:received:received; s=20200306; t=1701686530; bh=W/d/T 0OKhj1KT0T7UujZ4KoTrzercRBmRRp6qmWoS0A=; b=DGLfmOhUdmyUCU+mfpdQg a8V+CGkbL+HEaG8AZKZz9WjnyB+huOb0UKEbA/Pz7n7CEJbnQrrHUW53PDeOy8em NpOtUUrPDqpF0AALrUD87v46/glWWT+14/7DYis0ZL729pDg6wimmOwXsVGlhqXw hs9Di7S6Aegi9p1IncQbMtmCSvsbdqf/ZWLL3jeJId4cdSqoV9ki+B/hPM3w4Olp vJQYtIjZKZXIKi/CTqZ69tESF2wiJBdNqj5lPEDeLTGj5/XcvpW8PtFkHtF1R5yZ SUWKH4m89RkOHLRu/eeEY0+IOTq2aQZSemaKQ9E4MN77ZlaRVlx2vqgBcuYOx0bi w== X-Virus-Scanned: amavisd-new at cebitec.uni-bielefeld.de Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YQDOCLZP5xsY for ; Mon, 4 Dec 2023 11:42:10 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p4fddb508.dip0.t-ipconnect.de [79.221.181.8]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id EF876CF9FE for ; Mon, 4 Dec 2023 11:42:09 +0100 (CET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Subject: [PATCH] libssp: Fix gets-chk.c compilation on Solaris Date: Mon, 04 Dec 2023 11:42:09 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 X-Spam-Status: No, score=-3791.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+patchwork=sourceware.org@gcc.gnu.org The recent warning patches broke the libssp build on Solaris: /vol/gcc/src/hg/master/local/libssp/gets-chk.c: In function '__gets_chk': /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: implicit declaration of function 'gets'; did you mean 'getw'? [-Wimplicit-function-declaration] 67 | return gets (s); | ^~~~ | getw /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion] 67 | return gets (s); | ^~~~~~~~ /vol/gcc/src/hg/master/local/libssp/gets-chk.c:74:12: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion] 74 | return gets (s); | ^~~~~~~~ The guard around the gets declaration in gets-chk.c is #if !(!defined __USE_ISOC11 \ || (defined __cplusplus && __cplusplus <= 201103L)) extern char *gets (char *); #endif __USE_ISOC11 is a glibc-only thing, while Solaris declares gets like #if __STDC_VERSION__ < 201112L && __cplusplus < 201402L extern char *gets(char *) __ATTR_DEPRECATED; #endif If one needs to check __USE_ISO11 at all, one certainly needs to check __STDC_VERSION__ to avoid breaking every non-glibc target. Besides, I don't see what's the use of checking __cplusplus when compiling a C-only source file. On top of all that, the double negation makes the guard unnecessarily hard to understand. I really don't know if it's useful/appropriate to check __USE_ISOC11 and __cplusplus here at all; still I've left both for now. Here's what I've used to complete the Solaris bootstrap. Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and x86_64-apple-darwin23.1.0. # HG changeset patch # Parent 334015ab01f6c0e5af821c1e9bc83b8677cc0bfb libssp: Fix gets-chk.c compilation on Solaris diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c --- a/libssp/gets-chk.c +++ b/libssp/gets-chk.c @@ -51,8 +51,9 @@ see the files COPYING3 and COPYING.RUNTI # include #endif -#if !(!defined __USE_ISOC11 \ - || (defined __cplusplus && __cplusplus <= 201103L)) +#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) \ + || !defined __USE_ISOC11 \ + || (defined __cplusplus && __cplusplus >= 201402L) extern char *gets (char *); #endif