From patchwork Thu Jan 5 09:47:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 89975 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8886171qgi; Thu, 5 Jan 2017 01:48:36 -0800 (PST) X-Received: by 10.84.134.3 with SMTP id 3mr153490129plg.90.1483609716569; Thu, 05 Jan 2017 01:48:36 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r4si75312066pgr.239.2017.01.05.01.48.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2017 01:48:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445436-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445436-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445436-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=YF9tlx8bNvUzFqBYlasx9ragpviGzWFDLKx/sZRIvcNJRpTKrs cj0hJ5RUDMc2El0c4SmlftERELNjz9H33j5Ov4l3BRkC9k2+P2zKuhKE7zV4MqLt Wwa0P7kabDGbN8+6MYxIPDUJCSADxme27ql5TaInbGjqex1bsR4L1Ajk8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=/rvMgMb583X/JuQKbxWiu7cDnZU=; b=SfqlMu3GWaVZ0YUmW83n GM1ydGmjC0WOFvOb/UkHInsxqueyKmZs8S6loHJl9OLuOx+NTyhMl22ptJB1r5SE zZK8sgToV/YrbSz70ma7euIFSzP09pRt0IZF9ADPMe++8NvfeWeMimn/M1S763Hj fohr4Jq1EjcZANZ1m8wIbYA= Received: (qmail 78887 invoked by alias); 5 Jan 2017 09:48:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 78870 invoked by uid 89); 5 Jan 2017 09:48:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=MET, EDIT, 1216, january X-HELO: smtp.CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE (HELO smtp.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jan 2017 09:48:03 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id E7CB21E0; Thu, 5 Jan 2017 10:48:00 +0100 (CET) Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LPLxAEGuhM77; Thu, 5 Jan 2017 10:47:54 +0100 (CET) Received: from lokon.CeBiTec.Uni-Bielefeld.DE (lokon.CeBiTec.Uni-Bielefeld.DE [129.70.161.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 302F91DF; Thu, 5 Jan 2017 10:47:54 +0100 (CET) Received: (from ro@localhost) by lokon.CeBiTec.Uni-Bielefeld.DE (8.15.2+Sun/8.15.2/Submit) id v059lrZa011351; Thu, 5 Jan 2017 10:47:53 +0100 (MET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Bruce Korb , Jonathan Wakely Subject: [fixincludes] Only declare gets for C++ < 2014 on Solaris (PR libstdc++/78979) Date: Thu, 05 Jan 2017 10:47:53 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes While investigating PR libstdc++/78979, it turns out that Solaris incorrectly declares std::gets even for C++14 where it's been removed. This patch fixes that by adding an additional __cplusplus < 201402L guard via fixincludes. This works for Solaris 12 (and 11), but Solaris 10 declares the function unconditionally (i.e. without the __STDC_VERSION__ < 201112L guard and the deprecated attribute), so another fix adds both to handle that version, too. With this in place, the std::gets declaration in needs a guard, too. While testing this patch together with https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00288.html it turned out another fix is needed which I'm throwing in here, too: declares #if defined(_STDC_C11) extern _Noreturn void quick_exit(int); #else extern void quick_exit(int) __NORETURN; #endif /* _STDC_C11 */ and the first one now breaks badly with __STDC_VERSION__ defined to the C11 value: /usr/include/iso/stdlib_c99.h:83:8: error: '_Noreturn' does not name a type extern _Noreturn void quick_exit(int); ^~~~~~~~~ To avoid this, I've changed to C11-only _Noreturn to __attribute__((__noreturn__)). Bootstrapped without regressions on i386-pc-solaris2.1[02] and sparc-sun-solaris2.12 and fixing FAIL: 27_io/headers/cstdio/functions_neg.cc (test for errors, line 24) as designed. fixincludes make check, passes, too. Ok for mainline now? I'd like to backport the patch to the gcc-5 and gcc-6 branches which are equally affected. Thanks. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2017-01-04 Rainer Orth PR libstdc++/78979 * inclhack.def (solaris_gets_c11, solaris_gets_cxx14) (solaris_std_gets_cxx14, solaris_stdlib_noreturn): New fixes. * fixincl.x: Regenerate. * tests/base/iso/stdio_iso.h [SOLARIS_GETS_C11_CHECK, SOLARIS_GETS_CXX14_CHECK, SOLARIS_STD_GETS_CXX14_CHECK, SOLARIS_STDLIB_NORETURN_CHECK]: New tests. # HG changeset patch # Parent 8b946d3b0b1ff1d40660db201feee5925260f9ee Only declare gets for C++ < 2014 on Solaris (PR libstdc++/78979) diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed November 20, 2016 at 12:02:46 PM by AutoGen 5.16.2 + * It has been AutoGen-ed January 4, 2017 at 03:58:48 PM by AutoGen 5.16.2 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Nov 20 12:02:47 MET 2016 +/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Jan 4 15:58:48 2017 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 242 fixup descriptions. + * This file contains 245 fixup descriptions. * * See README for more information. * @@ -7068,6 +7068,84 @@ static const char* apzSolaris_Getc_Stric /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Solaris_Gets_C11 fix + */ +tSCC zSolaris_Gets_C11Name[] = + "solaris_gets_c11"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Gets_C11List[] = + "iso/stdio_iso.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Gets_C11Machs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Gets_C11Select0[] = + "(extern char[ \t]*\\*gets\\(char \\*\\));"; + +#define SOLARIS_GETS_C11_TEST_CT 1 +static tTestDesc aSolaris_Gets_C11Tests[] = { + { TT_EGREP, zSolaris_Gets_C11Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Gets_C11 + */ +static const char* apzSolaris_Gets_C11Patch[] = { + "format", + "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n\ +%1 __attribute__((__deprecated__));\n\ +#endif", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Solaris_Gets_Cxx14 fix + */ +tSCC zSolaris_Gets_Cxx14Name[] = + "solaris_gets_cxx14"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Gets_Cxx14List[] = + "iso/stdio_iso.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Gets_Cxx14Machs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Gets_Cxx14Select0[] = + "(#if __STDC_VERSION__ < 201112L)\n\ +(extern char\t\\*gets\\(char \\*\\) __ATTR_DEPRECATED;)"; + +#define SOLARIS_GETS_CXX14_TEST_CT 1 +static tTestDesc aSolaris_Gets_Cxx14Tests[] = { + { TT_EGREP, zSolaris_Gets_Cxx14Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Gets_Cxx14 + */ +static const char* apzSolaris_Gets_Cxx14Patch[] = { + "format", + "%1 && __cplusplus < 201402L\n\ +%2", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Solaris_Int_Const fix */ tSCC zSolaris_Int_ConstName[] = @@ -7820,6 +7898,45 @@ using std::__flsbuf;\n\ /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Solaris_Std_Gets_Cxx14 fix + */ +tSCC zSolaris_Std_Gets_Cxx14Name[] = + "solaris_std_gets_cxx14"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Std_Gets_Cxx14List[] = + "stdio.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Std_Gets_Cxx14Machs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Std_Gets_Cxx14Select0[] = + "using std::gets;"; + +#define SOLARIS_STD_GETS_CXX14_TEST_CT 1 +static tTestDesc aSolaris_Std_Gets_Cxx14Tests[] = { + { TT_EGREP, zSolaris_Std_Gets_Cxx14Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Std_Gets_Cxx14 + */ +static const char* apzSolaris_Std_Gets_Cxx14Patch[] = { + "format", + "#if __cplusplus < 201402L\n\ +%0\n\ +#endif", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Solaris_Stdio_Tag fix */ tSCC zSolaris_Stdio_TagName[] = @@ -9908,9 +10025,9 @@ static const char* apzX11_SprintfPatch[] * * List of all fixes */ -#define REGEX_COUNT 279 +#define REGEX_COUNT 282 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 242 +#define FIX_COUNT 245 /* * Enumerate the fixes @@ -10087,6 +10204,8 @@ typedef enum { SOLARIS_COMPLEX_CXX_FIXIDX, SOLARIS_CXX_LINKAGE_FIXIDX, SOLARIS_GETC_STRICT_STDC_FIXIDX, + SOLARIS_GETS_C11_FIXIDX, + SOLARIS_GETS_CXX14_FIXIDX, SOLARIS_INT_CONST_FIXIDX, SOLARIS_INT_LIMITS_1_FIXIDX, SOLARIS_INT_LIMITS_2_FIXIDX, @@ -10105,6 +10224,7 @@ typedef enum { SOLARIS_POW_INT_OVERLOAD_FIXIDX, SOLARIS_RWLOCK_INIT_1_FIXIDX, SOLARIS_STD___FILBUF_FIXIDX, + SOLARIS_STD_GETS_CXX14_FIXIDX, SOLARIS_STDIO_TAG_FIXIDX, STATSSWTCH_FIXIDX, STDIO_STDARG_H_FIXIDX, @@ -11016,6 +11136,16 @@ tFixDesc fixDescList[ FIX_COUNT ] = { SOLARIS_GETC_STRICT_STDC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aSolaris_Getc_Strict_StdcTests, apzSolaris_Getc_Strict_StdcPatch, 0 }, + { zSolaris_Gets_C11Name, zSolaris_Gets_C11List, + apzSolaris_Gets_C11Machs, + SOLARIS_GETS_C11_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Gets_C11Tests, apzSolaris_Gets_C11Patch, 0 }, + + { zSolaris_Gets_Cxx14Name, zSolaris_Gets_Cxx14List, + apzSolaris_Gets_Cxx14Machs, + SOLARIS_GETS_CXX14_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Gets_Cxx14Tests, apzSolaris_Gets_Cxx14Patch, 0 }, + { zSolaris_Int_ConstName, zSolaris_Int_ConstList, apzSolaris_Int_ConstMachs, SOLARIS_INT_CONST_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, @@ -11106,6 +11236,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { SOLARIS_STD___FILBUF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aSolaris_Std___FilbufTests, apzSolaris_Std___FilbufPatch, 0 }, + { zSolaris_Std_Gets_Cxx14Name, zSolaris_Std_Gets_Cxx14List, + apzSolaris_Std_Gets_Cxx14Machs, + SOLARIS_STD_GETS_CXX14_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Std_Gets_Cxx14Tests, apzSolaris_Std_Gets_Cxx14Patch, 0 }, + { zSolaris_Stdio_TagName, zSolaris_Stdio_TagList, apzSolaris_Stdio_TagMachs, SOLARIS_STDIO_TAG_TEST_CT, FD_MACH_ONLY, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -3593,6 +3593,43 @@ fix = { }; /* + * Solaris should deprecate gets before C11. + */ +fix = { + hackname = solaris_gets_c11; + mach = "*-*-solaris2*"; + files = "iso/stdio_iso.h"; + select = "(extern char[ \t]*\\*gets\\(char \\*\\));"; + + c_fix = format; + c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n" + "%1 __attribute__((__deprecated__));\n" + "#endif"; + + test_text = "extern char *gets(char *);"; +}; + +/* + * Solaris shouldn't declare gets for C++14. + */ +fix = { + hackname = solaris_gets_cxx14; + mach = "*-*-solaris2*"; + files = "iso/stdio_iso.h"; + select = <<- _EOSelect_ +(#if __STDC_VERSION__ < 201112L) +(extern char \*gets\(char \*\) __ATTR_DEPRECATED;) +_EOSelect_; + c_fix = format; + c_fix_arg = "%1 && __cplusplus < 201402L\n%2"; + + test_text = <<- _EOText_ +#if __STDC_VERSION__ < 201112L +extern char *gets(char *) __ATTR_DEPRECATED; +_EOText_; +}; + +/* * Sun Solaris 2 has a version of sys/int_const.h that defines * UINT8_C and UINT16_C to unsigned constants. */ @@ -3982,6 +4019,21 @@ fix = { }; /* + * Solaris shouldn't use std::gets for C++14. + */ +fix = { + hackname = solaris_std_gets_cxx14; + mach = "*-*-solaris2*"; + files = "stdio.h"; + select = "using std::gets;"; + + c_fix = format; + c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif"; + + test_text = "using std::gets;"; +}; + +/* * Sun Solaris 8 has what appears to be some gross workaround for * some old version of their c++ compiler. G++ doesn't want it * either, but doesn't want to be tied to SunPRO version numbers. diff --git a/fixincludes/tests/base/iso/stdio_iso.h b/fixincludes/tests/base/iso/stdio_iso.h --- a/fixincludes/tests/base/iso/stdio_iso.h +++ b/fixincludes/tests/base/iso/stdio_iso.h @@ -12,3 +12,16 @@ #if defined( SOLARIS_GETC_STRICT_STDC_CHECK ) #if !defined(_REENTRANT) && !defined(_LP64) && (!defined(_STRICT_STDC) || (__cplusplus >= 199711L)) #endif /* SOLARIS_GETC_STRICT_STDC_CHECK */ + + +#if defined( SOLARIS_GETS_C11_CHECK ) +#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L +extern char *gets(char *) __attribute__((__deprecated__)); +#endif +#endif /* SOLARIS_GETS_C11_CHECK */ + + +#if defined( SOLARIS_GETS_CXX14_CHECK ) +#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L +extern char *gets(char *) __ATTR_DEPRECATED; +#endif /* SOLARIS_GETS_CXX14_CHECK */ diff --git a/fixincludes/tests/base/stdio.h b/fixincludes/tests/base/stdio.h --- a/fixincludes/tests/base/stdio.h +++ b/fixincludes/tests/base/stdio.h @@ -90,6 +90,13 @@ using std::__flsbuf; #endif /* SOLARIS_STD___FILBUF_CHECK */ +#if defined( SOLARIS_STD_GETS_CXX14_CHECK ) +#if __cplusplus < 201402L +using std::gets; +#endif +#endif /* SOLARIS_STD_GETS_CXX14_CHECK */ + + #if defined( STDIO_STDARG_H_CHECK ) #endif /* STDIO_STDARG_H_CHECK */