public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, libcpp] SD-6 feature macros
@ 2014-08-18 21:32 Thiago Macieira
  2014-09-01 22:45 ` Thiago Macieira
  0 siblings, 1 reply; 2+ messages in thread
From: Thiago Macieira @ 2014-08-18 21:32 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

Hello

The SD-6 [1] document keeps a list of built-in #defines that allow application 
and library writers know when certain language and library features have been 
implemented by the compiler. They are optional, since a compliant compiler 
must implement them all.

But they're really useful.

This patch provides the defines for current GCC 4.9. I don't see anything in 
http://gcc.gnu.org/projects/cxx1y.html that indicates newly supported features 
for trunk, so the patch should apply to both branches now.

This patch does not add the SD-6 defines to libstdc++.

[1] N3745 and 
http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

[-- Attachment #2: SD6_feature_macros.patch --]
[-- Type: text/x-patch, Size: 2990 bytes --]

From 5cb90354d18c4edc1dcc11cf3674542409597863 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Mon, 18 Aug 2014 11:43:36 -0700
Subject: [PATCH 1/1] 2014-08-18  Thiago Macieira <thiago.macieira@intel.com>

	* init.c (cpp_init_builtins ()): Set the SD-6 feature defines
	in C++11 and C++14 modes.
---
 libcpp/init.c | 50 ++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/libcpp/init.c b/libcpp/init.c
index f10413a..1a9d046 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -485,14 +485,48 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
 
   if (CPP_OPTION (pfile, cplusplus))
     {
-      if (CPP_OPTION (pfile, lang) == CLK_CXX1Y
-	  || CPP_OPTION (pfile, lang) == CLK_GNUCXX1Y)
-	_cpp_define_builtin (pfile, "__cplusplus 201300L");
-      else if (CPP_OPTION (pfile, lang) == CLK_CXX11
-	       || CPP_OPTION (pfile, lang) == CLK_GNUCXX11)
-	_cpp_define_builtin (pfile, "__cplusplus 201103L");
-      else
-	_cpp_define_builtin (pfile, "__cplusplus 199711L");
+      switch (CPP_OPTION (pfile, lang))
+	{
+	  case CLK_GNUCXX1Y:
+	  case CLK_CXX1Y:
+	    _cpp_define_builtin (pfile, "__cpp_init_captures 201304");
+	    _cpp_define_builtin (pfile, "__cpp_decltype_auto 201304");
+	    _cpp_define_builtin (pfile, "__cpp_return_type_deduction 201304");
+	    if (CPP_OPTION (pfile, lang) == CLK_CXX1Y
+		|| CPP_OPTION (pfile, lang) == CLK_GNUCXX1Y)
+	      _cpp_define_builtin (pfile, "__cplusplus 201300L");
+	    /* fall through */
+
+	  case CLK_GNUCXX11:
+	  case CLK_CXX11:
+	    _cpp_define_builtin (pfile, "__cpp_unicode_characters 200704");
+	    _cpp_define_builtin (pfile, "__cpp_unicode_literals 200710");
+	    _cpp_define_builtin (pfile, "__cpp_unicode_literals 200710");
+	    _cpp_define_builtin (pfile, "__cpp_user_defined_literals 200809");
+	    _cpp_define_builtin (pfile, "__cpp_lambdas 200907");
+	    _cpp_define_builtin (pfile, "__cpp_static_assert 200410");
+	    _cpp_define_builtin (pfile, "__cpp_decltype 200707");
+	    _cpp_define_builtin (pfile, "__cpp_attributes 200809");
+	    _cpp_define_builtin (pfile, "__cpp_rvalue_references 200610");
+	    _cpp_define_builtin (pfile, "__cpp_variadic_templates 200704");
+	    if (CPP_OPTION (pfile, lang) == CLK_CXX11
+		|| CPP_OPTION (pfile, lang) == CLK_GNUCXX11)
+	      {
+		_cpp_define_builtin (pfile, "__cplusplus 201103L");
+		_cpp_define_builtin (pfile, "__cpp_constexpr 200704");
+	      }
+	    if (CPP_OPTION (pfile, lang) == CLK_CXX11)
+	      break;
+	    /* fall through */
+
+	  default:
+	    if (CPP_OPTION (pfile, lang) == CLK_CXX98
+		|| CPP_OPTION (pfile, lang) == CLK_GNUCXX)
+	      _cpp_define_builtin (pfile, "__cplusplus 199711L");
+	    if (CPP_OPTION (pfile, lang) == CLK_CXX98)
+	      break;
+	    _cpp_define_builtin (pfile, "__cpp_binary_literals 201304");
+	}
     }
   else if (CPP_OPTION (pfile, lang) == CLK_ASM)
     _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
-- 
1.8.4.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, libcpp] SD-6 feature macros
  2014-08-18 21:32 [PATCH, libcpp] SD-6 feature macros Thiago Macieira
@ 2014-09-01 22:45 ` Thiago Macieira
  0 siblings, 0 replies; 2+ messages in thread
From: Thiago Macieira @ 2014-09-01 22:45 UTC (permalink / raw)
  To: gcc-patches

On Monday 18 August 2014 14:32:04 Thiago Macieira wrote:
> Hello
> 
> The SD-6 [1] document keeps a list of built-in #defines that allow
> application and library writers know when certain language and library
> features have been implemented by the compiler. They are optional, since a
> compliant compiler must implement them all.
> 
> But they're really useful.
> 
> This patch provides the defines for current GCC 4.9. I don't see anything in
> http://gcc.gnu.org/projects/cxx1y.html that indicates newly supported
> features for trunk, so the patch should apply to both branches now.
> 
> This patch does not add the SD-6 defines to libstdc++.
> 
> [1] N3745 and
> http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendati
> ons

Hello

I sent this two weeks ago. There has been no comment suggesting improvements 
required. I'm taking that as "no further changes needed, this looks good".

I don't have a Subversion account. Could someone apply the patch, please?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-01 22:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-18 21:32 [PATCH, libcpp] SD-6 feature macros Thiago Macieira
2014-09-01 22:45 ` Thiago Macieira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).