diff mbox

Require C11 for C++17 on Solaris

Message ID yddfukxc0pk.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Jan. 5, 2017, 9:31 a.m. UTC
While investigating PR libstdc++/78979, it turned out that g++ on
Solaris should define the C11 value for __STDC_VERSION__ instead of the
C99 one when compiling for C++17.

That's what this patch does.  It seemed safer to use the C99 value only
where we know it's needed, and default to the C11 one to be future-proof
for versions of C++ beyond 2017.

Bootstrapped without regressions on i386-pc-solaris2.1[10] and
sparc-sun-solaris2.12 (together with the soon-to-be-submitted patch for
the PR itself).

Unless Jon or someone else finds fault with the approach, I plan to
commit it to mainline soon.

	Rainer
diff mbox

Patch

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -94,7 +94,22 @@  along with GCC; see the file COPYING3.  
 	   library.  */					\
 	if (c_dialect_cxx ())				\
 	  {						\
+	switch (cxx_dialect)				\
+	  {						\
+	  case cxx98:					\
+	  case cxx11:					\
+	  case cxx14:					\
+	    /* C++11 and C++14 are based on C99.	\
+	       libstdc++ makes use of C99 features	\
+	       even for C++98.  */			\
 	    builtin_define ("__STDC_VERSION__=199901L");\
+	    break;					\
+							\
+	  default:					\
+	    /* C++17 is based on C11.  */		\
+	    builtin_define ("__STDC_VERSION__=201112L");\
+	    break;					\
+	  }						\
 	    builtin_define ("_XOPEN_SOURCE=600");	\
 	    builtin_define ("_LARGEFILE_SOURCE=1");	\
 	    builtin_define ("_LARGEFILE64_SOURCE=1");	\