From babc47283189c5cae91cfe13fd20b0633145655c Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date: Mon, 21 Jun 2010 15:27:29 +0000
Subject: [PATCH] sol2.h (TARGET_OS_CPP_BUILTINS): Define
 __STDC_VERSION__=199901L, _XOPEN_SOURCE=600 for C++.

	gcc:
	* config/sol2.h (TARGET_OS_CPP_BUILTINS): Define
	__STDC_VERSION__=199901L, _XOPEN_SOURCE=600 for C++.

	fixincludes:
	* inclhack.def (solaris__restrict, solaris_complex_cxx): New fixes
	* fixincl.x: Regenerate.
	* tests/base/complex.h [SOLARIS_COMPLEX_CXX_CHECK]: New test.
	* tests/base/sys/feature_tests.h: New file.

	libstdc++-v3:
	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc:
	Add *-*-solaris2.1[0-9]* to dg-xfail-if, dg-excess-errors.

From-SVN: r161089
---
 fixincludes/ChangeLog                         |  7 ++
 fixincludes/fixincl.x                         | 96 ++++++++++++++++++-
 fixincludes/inclhack.def                      | 34 +++++++
 fixincludes/tests/base/complex.h              | 10 ++
 fixincludes/tests/base/sys/feature_tests.h    | 18 ++++
 gcc/ChangeLog                                 |  5 +
 gcc/config/sol2.h                             |  3 +-
 libstdc++-v3/ChangeLog                        |  5 +
 .../cmath/c99_classification_macros_c.cc      |  4 +-
 9 files changed, 174 insertions(+), 8 deletions(-)
 create mode 100644 fixincludes/tests/base/sys/feature_tests.h

diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog
index 274d0039723d..11c4e695ea1f 100644
--- a/fixincludes/ChangeLog
+++ b/fixincludes/ChangeLog
@@ -1,3 +1,10 @@
+2010-06-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* inclhack.def (solaris__restrict, solaris_complex_cxx): New fixes
+	* fixincl.x: Regenerate.
+	* tests/base/complex.h [SOLARIS_COMPLEX_CXX_CHECK]: New test.
+	* tests/base/sys/feature_tests.h: New file.
+
 2010-06-03  Joern Rennecke <joern.rennecke@embecosm.com>
 	    Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index e80d50c5adcc..88ad8434020a 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Wednesday April  7, 2010 at 05:11:50 PM MEST
+ * It has been AutoGen-ed  Friday May  7, 2010 at 02:41:29 PM MEST
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Apr  7 17:11:50 MEST 2010
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri May  7 14:41:29 MEST 2010
  *
  * 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 205 fixup descriptions.
+ * This file contains 207 fixup descriptions.
  *
  * See README for more information.
  *
@@ -6114,6 +6114,47 @@ static const char* apzRs6000_ParamPatch[] = {
     "rename(const char *_old, const char *_new)",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Solaris___Restrict fix
+ */
+tSCC zSolaris___RestrictName[] =
+     "solaris___restrict";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zSolaris___RestrictList[] =
+  "sys/feature_tests.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzSolaris___RestrictMachs[] = {
+        "*-*-solaris2*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zSolaris___RestrictSelect0[] =
+       "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
+
+#define    SOLARIS___RESTRICT_TEST_CT  1
+static tTestDesc aSolaris___RestrictTests[] = {
+  { TT_EGREP,    zSolaris___RestrictSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Solaris___Restrict
+ */
+static const char* apzSolaris___RestrictPatch[] = {
+    "format",
+    "#ifdef __cplusplus\n\
+#define\t_RESTRICT_KYWD\t__restrict\n\
+#else\n\
+%0\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Solaris_Complex fix
@@ -6153,6 +6194,39 @@ static const char* apzSolaris_ComplexPatch[] = { sed_cmd_z,
     "-e", "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Solaris_Complex_Cxx fix
+ */
+tSCC zSolaris_Complex_CxxName[] =
+     "solaris_complex_cxx";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zSolaris_Complex_CxxList[] =
+  "complex.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzSolaris_Complex_CxxMachs[] = {
+        "*-*-solaris2.*",
+        (const char*)NULL };
+#define SOLARIS_COMPLEX_CXX_TEST_CT  0
+#define aSolaris_Complex_CxxTests   (tTestDesc*)NULL
+
+/*
+ *  Fix Command Arguments for Solaris_Complex_Cxx
+ */
+static const char* apzSolaris_Complex_CxxPatch[] = { sed_cmd_z,
+    "-e", "/#if[ \t]*!defined(__cplusplus)/c#ifdef\t__cplusplus\\\n\
+extern \"C\" {\\\n\
+#endif",
+    "-e", "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c#ifdef\t__cplusplus\\\n\
+}\\\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Solaris_Math_1 fix
@@ -8358,9 +8432,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          245
+#define REGEX_COUNT          246
 #define MACH_LIST_SIZE_LIMIT 181
-#define FIX_COUNT            205
+#define FIX_COUNT            207
 
 /*
  *  Enumerate the fixes
@@ -8516,7 +8590,9 @@ typedef enum {
     RS6000_DOUBLE_FIXIDX,
     RS6000_FCHMOD_FIXIDX,
     RS6000_PARAM_FIXIDX,
+    SOLARIS___RESTRICT_FIXIDX,
     SOLARIS_COMPLEX_FIXIDX,
+    SOLARIS_COMPLEX_CXX_FIXIDX,
     SOLARIS_MATH_1_FIXIDX,
     SOLARIS_MATH_2_FIXIDX,
     SOLARIS_MATH_3_FIXIDX,
@@ -9324,11 +9400,21 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      RS6000_PARAM_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aRs6000_ParamTests,   apzRs6000_ParamPatch, 0 },
 
+  {  zSolaris___RestrictName,    zSolaris___RestrictList,
+     apzSolaris___RestrictMachs,
+     SOLARIS___RESTRICT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aSolaris___RestrictTests,   apzSolaris___RestrictPatch, 0 },
+
   {  zSolaris_ComplexName,    zSolaris_ComplexList,
      apzSolaris_ComplexMachs,
      SOLARIS_COMPLEX_TEST_CT, FD_MACH_ONLY,
      aSolaris_ComplexTests,   apzSolaris_ComplexPatch, 0 },
 
+  {  zSolaris_Complex_CxxName,    zSolaris_Complex_CxxList,
+     apzSolaris_Complex_CxxMachs,
+     SOLARIS_COMPLEX_CXX_TEST_CT, FD_MACH_ONLY,
+     aSolaris_Complex_CxxTests,   apzSolaris_Complex_CxxPatch, 0 },
+
   {  zSolaris_Math_1Name,    zSolaris_Math_1List,
      apzSolaris_Math_1Machs,
      SOLARIS_MATH_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 4f70a9f3a640..16f36a1e74ab 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -3248,6 +3248,23 @@ fix = {
 };
 
 
+/*
+ *  Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
+ *  for C99.  This is wrong for C++, which needs many C99 features, but
+ *  only supports __restrict.
+ */
+fix = {
+    hackname  = solaris___restrict;
+    files     = sys/feature_tests.h;
+    select    = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
+    mach      = "*-*-solaris2*";
+    c_fix     = format;
+    c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
+    	        "#else\n%0\n#endif";
+    test_text = "#define	_RESTRICT_KYWD	restrict";
+};
+
+
 /*
  * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
  * themselves, which are Sun Studio compiler intrinsics.  Remove _Imaginary_I
@@ -3272,6 +3289,23 @@ fix = {
 };
 
 
+/*
+ * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus.  Wrap in
+ * extern "C" instead so libstdc++ can use it.
+ */
+fix = {
+    hackname  = solaris_complex_cxx;
+    mach      = "*-*-solaris2.*";
+    files     = complex.h;
+    sed	      = "/#if[ \t]*!defined(__cplusplus)/c"
+    		"#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
+    sed	      = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c"
+		"#ifdef\t__cplusplus\\\n}\\\n#endif";
+    test_text = "#if !defined(__cplusplus)\n"
+		"#endif	/* !defined(__cplusplus) */";
+};
+
+
 /*
  * Sun Solaris 10 defines several C99 math macros in terms of
  * builtins specific to the Studio compiler, in particular not
diff --git a/fixincludes/tests/base/complex.h b/fixincludes/tests/base/complex.h
index 9a54e8c0bda6..b3fe27aca2ea 100644
--- a/fixincludes/tests/base/complex.h
+++ b/fixincludes/tests/base/complex.h
@@ -33,3 +33,13 @@
 #undef	I
 #define	I		_Complex_I
 #endif  /* SOLARIS_COMPLEX_CHECK */
+
+
+#if defined( SOLARIS_COMPLEX_CXX_CHECK )
+#ifdef	__cplusplus
+extern "C" {
+#endif
+#ifdef	__cplusplus
+}
+#endif
+#endif  /* SOLARIS_COMPLEX_CXX_CHECK */
diff --git a/fixincludes/tests/base/sys/feature_tests.h b/fixincludes/tests/base/sys/feature_tests.h
new file mode 100644
index 000000000000..3bb803c288d9
--- /dev/null
+++ b/fixincludes/tests/base/sys/feature_tests.h
@@ -0,0 +1,18 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/sys/feature_tests.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( SOLARIS___RESTRICT_CHECK )
+#ifdef __cplusplus
+#define	_RESTRICT_KYWD	__restrict
+#else
+#define	_RESTRICT_KYWD	restrict
+#endif
+#endif  /* SOLARIS___RESTRICT_CHECK */
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0a73e940e239..68bb4f0aa61b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* config/sol2.h (TARGET_OS_CPP_BUILTINS): Define
+	__STDC_VERSION__=199901L, _XOPEN_SOURCE=600 for C++.
+
 2010-06-21  Nick Clifton  <nickc@redhat.com>
 
 	* config/rx/rx.h (PTRDIFF_TYPE): Define.
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index 98e54e6a92c7..7b7ce2bfbab2 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -99,7 +99,8 @@ along with GCC; see the file COPYING3.  If not see
 	   library.  */					\
 	if (c_dialect_cxx ())				\
 	  {						\
-	    builtin_define ("_XOPEN_SOURCE=500");	\
+	    builtin_define ("__STDC_VERSION__=199901L");\
+	    builtin_define ("_XOPEN_SOURCE=600");	\
 	    builtin_define ("_LARGEFILE_SOURCE=1");	\
 	    builtin_define ("_LARGEFILE64_SOURCE=1");	\
 	    builtin_define ("__EXTENSIONS__");		\
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2d9791587110..332c22f28acd 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc:
+	Add *-*-solaris2.1[0-9]* to dg-xfail-if, dg-excess-errors.
+
 2010-06-20  Paolo Carlini  <paolo.carlini@oracle.com>
 	    Kai-Uwe Bux  <bux@kubux.net>
 
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc
index 142e1da38bd1..716dda51b1ef 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc
@@ -20,8 +20,8 @@
 // { dg-do compile }
 // { dg-add-options no_pch }
 
-// { dg-xfail-if "" { { *-*-linux* *-*-darwin* hppa*-*-hpux* } || { uclibc || newlib } } { "*" } { "" } }
-// { dg-excess-errors "" { target { { *-*-linux* *-*-darwin* hppa*-*-hpux* } || { uclibc || newlib } } } }
+// { dg-xfail-if "" { { *-*-linux* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* } || { uclibc || newlib } } { "*" } { "" } }
+// { dg-excess-errors "" { target { { *-*-linux* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* } || { uclibc || newlib } } } }
 
 #include <math.h>
 
-- 
GitLab