diff mbox

Fix PR bootstrap/51705

Message ID 20111230041251.GA51358@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Dec. 30, 2011, 4:12 a.m. UTC
The audit trail in the PR pretty much sums up the problem.
OK to commit?

2011-12-29  Steven G. Kargl  <kargl@gcc.gnu.org>

	* inclhack.def:  Disgusting hack to workaround brain damage of
	defining __cplusplus as 201103L with -std=c++11 when g++ does
	not support c++11.
	* fixincl.x: regenerated.
	* genfixes: Fix to version test.

Comments

Jakub Jelinek Dec. 30, 2011, 9:38 a.m. UTC | #1
On Thu, Dec 29, 2011 at 08:12:51PM -0800, Steve Kargl wrote:
> The audit trail in the PR pretty much sums up the problem.
> OK to commit?

Can you tune up the comments a little bit?
If you look up http://gcc.gnu.org/gcc-4.7/cxx0x_status.html
you'll see that most of the C++11 features are already implemented
(and e.g. at_quick_exit is implemented too in some libcs), so the
__cplusplus macro isn't lying.  Clang apparently defines __cplusplus
to 201103L much longer than GCC does, yet it supports much smaller subset
of C++11.  Apparently it parses the C++11 generalized attribute syntax,
but at least clang 3.0 doesn't complain at all about anything between
the [[ and ]] pair, [[foobar, foobaz (bar, baz, 2, 6, 0x1z2)]] void bar (void);
is parsed just fine, and with [[noreturn]] it miscompiles even the first
[[noreturn]] trivial testcase I wrote.
See
http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02027.html
for why we set __cplusplus to the value we do.
So please leave about the "disgusting", "brain damage", "lies" etc.

> 2011-12-29  Steven G. Kargl  <kargl@gcc.gnu.org>
> 
> 	* inclhack.def:  Disgusting hack to workaround brain damage of
> 	defining __cplusplus as 201103L with -std=c++11 when g++ does
> 	not support c++11.
> 	* fixincl.x: regenerated.
> 	* genfixes: Fix to version test.
> 
> -- 
> Steve

> Index: inclhack.def
> ===================================================================
> --- inclhack.def	(revision 182738)
> +++ inclhack.def	(working copy)
> @@ -20,6 +20,21 @@ autogen definitions fixincl;
>  FIXINC_DEBUG = yes;
>  #endif
>  
> +/*
> + * g++ -std=c++11 defines __cplusplus to 201103L, which lies about
> + * the level of support g++ has for the C++11 standard.
> + */

	Jakub
diff mbox

Patch

Index: inclhack.def
===================================================================
--- inclhack.def	(revision 182738)
+++ inclhack.def	(working copy)
@@ -20,6 +20,21 @@  autogen definitions fixincl;
 FIXINC_DEBUG = yes;
 #endif
 
+/*
+ * g++ -std=c++11 defines __cplusplus to 201103L, which lies about
+ * the level of support g++ has for the C++11 standard.
+ */
+fix = {
+    hackname  = cdef_cplusplus;
+    mach      = "*-*-freebsd10.*";
+    files     = sys/cdefs.h;
+    select    = "\\\\[\\\\[noreturn\\\\]\\\\]";
+    sed       = "s/\\\\[\\\\[noreturn\\\\]\\\\]/__dead2/";
+    test_text = "#include <sys/cdefs.h>";
+};
+
+
+
 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
  * fopen64 etc. and this causes problems when building with g++
  * because cstdio udefs everything from stdio.h, leaving us with
Index: fixincl.x
===================================================================
--- fixincl.x	(revision 182738)
+++ fixincl.x	(working copy)
@@ -2,11 +2,11 @@ 
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  November  7, 2011 at 01:16:39 PM by AutoGen 5.10
+ * It has been AutoGen-ed  December 29, 2011 at 06:29:22 PM by AutoGen 5.12
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Nov  7 13:16:39 EST 2011
+/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Dec 29 18:29:22 PST 2011
  *
  * 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 222 fixup descriptions.
+ * This file contains 223 fixup descriptions.
  *
  * See README for more information.
  *
@@ -43,6 +43,42 @@  static char const sed_cmd_z[] = SED_PROG
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  Description of Cdef_Cplusplus fix
+ */
+tSCC zCdef_CplusplusName[] =
+     "cdef_cplusplus";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zCdef_CplusplusList[] =
+  "sys/cdefs.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzCdef_CplusplusMachs[] = {
+        "*-*-freebsd10.*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zCdef_CplusplusSelect0[] =
+       "\\\\[\\\\[noreturn\\\\]\\\\]";
+
+#define    CDEF_CPLUSPLUS_TEST_CT  1
+static tTestDesc aCdef_CplusplusTests[] = {
+  { TT_EGREP,    zCdef_CplusplusSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Cdef_Cplusplus
+ */
+static const char* apzCdef_CplusplusPatch[] = { sed_cmd_z,
+    "-e", "s/\\\\[\\\\[noreturn\\\\]\\\\]/__dead2/",
+    (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
  *  Description of Aab_Aix_Stdio fix
  */
 tSCC zAab_Aix_StdioName[] =
@@ -9034,14 +9070,15 @@  static const char* apzX11_SprintfPatch[]
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          264
+#define REGEX_COUNT          265
 #define MACH_LIST_SIZE_LIMIT 181
-#define FIX_COUNT            222
+#define FIX_COUNT            223
 
 /*
  *  Enumerate the fixes
  */
 typedef enum {
+    CDEF_CPLUSPLUS_FIXIDX,
     AAB_AIX_STDIO_FIXIDX,
     AAB_DARWIN7_9_LONG_DOUBLE_FUNCS_FIXIDX,
     AAB_DARWIN7_9_LONG_DOUBLE_FUNCS_2_FIXIDX,
@@ -9267,6 +9304,11 @@  typedef enum {
 } t_fixinc_idx;
 
 tFixDesc fixDescList[ FIX_COUNT ] = {
+  {  zCdef_CplusplusName,    zCdef_CplusplusList,
+     apzCdef_CplusplusMachs,
+     CDEF_CPLUSPLUS_TEST_CT, FD_MACH_ONLY,
+     aCdef_CplusplusTests,   apzCdef_CplusplusPatch, 0 },
+
   {  zAab_Aix_StdioName,    zAab_Aix_StdioList,
      apzAab_Aix_StdioMachs,
      AAB_AIX_STDIO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
Index: genfixes
===================================================================
--- genfixes	(revision 182738)
+++ genfixes	(working copy)
@@ -62,7 +62,7 @@  fi
 AG="autogen $AG"
 set -e
 
-if [ -z "`${AG} -v | fgrep 'Ver. 5.'`" ]
+if [ -z "`${AG} -v | fgrep '5.'`" ]
 then
   echo "AutoGen appears to be out of date or not correctly installed."
   echo "Please download and install:"