diff mbox

C++ PATCH for missing feature test macros

Message ID 56259258.5010205@redhat.com
State New
Headers show

Commit Message

Jason Merrill Oct. 20, 2015, 1:01 a.m. UTC
Someone pointed out that we were missing feature test macros for some 
recently implemented C++1z features; this patch fixes that.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit cb8271fe1b49b984fa38dc6cf1d3ed25462afd20
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Oct 18 10:15:36 2015 -1000

    	* c-cppbuiltin.c (c_cpp_builtins): Define
    	__cpp_enumerator_attributes, __cpp_fold_expressions,
    	__cpp_unicode_characters.

diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 35d246b..cd6fd51 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -833,7 +833,8 @@  c_cpp_builtins (cpp_reader *pfile)
       if (cxx_dialect >= cxx11)
 	{
 	  /* Set feature test macros for C++11.  */
-	  cpp_define (pfile, "__cpp_unicode_characters=200704");
+	  if (cxx_dialect <= cxx14)
+	    cpp_define (pfile, "__cpp_unicode_characters=200704");
 	  cpp_define (pfile, "__cpp_raw_strings=200710");
 	  cpp_define (pfile, "__cpp_unicode_literals=200710");
 	  cpp_define (pfile, "__cpp_user_defined_literals=200809");
@@ -869,9 +870,12 @@  c_cpp_builtins (cpp_reader *pfile)
       if (cxx_dialect > cxx14)
 	{
 	  /* Set feature test macros for C++1z.  */
+	  cpp_define (pfile, "__cpp_unicode_characters=201411");
 	  cpp_define (pfile, "__cpp_static_assert=201411");
 	  cpp_define (pfile, "__cpp_namespace_attributes=201411");
+	  cpp_define (pfile, "__cpp_enumerator_attributes=201411");
 	  cpp_define (pfile, "__cpp_nested_namespace_definitions=201411");
+	  cpp_define (pfile, "__cpp_fold_expressions=201411");
 	}
       if (flag_concepts)
 	/* Use a value smaller than the 201507 specified in
diff --git a/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1.C b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1.C
new file mode 100644
index 0000000..1f8f848
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1.C
@@ -0,0 +1,9 @@ 
+// { dg-options "-std=c++1z" }
+
+#ifndef __cpp_enumerator_attributes
+#error __cpp_enumerator_attributes not defined
+#endif
+
+#if __cpp_enumerator_attributes != 201411
+#error Wrong value for __cpp_enumerator_attributes
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
new file mode 100644
index 0000000..f321ba1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
@@ -0,0 +1,5 @@ 
+// This macro should not be defined without -std=c++1z.
+
+#ifdef __cpp_enumerator_attributes
+#error __cpp_enumerator_attributes defined
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/fold7.C b/gcc/testsuite/g++.dg/cpp1z/fold7.C
new file mode 100644
index 0000000..3e6925a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/fold7.C
@@ -0,0 +1,9 @@ 
+// { dg-options "-std=c++1z" }
+
+#ifndef __cpp_fold_expressions
+#error __cpp_fold_expressions not defined
+#endif
+
+#if __cpp_fold_expressions != 201411
+#error Wrong value for __cpp_fold_expressions
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/fold7a.C b/gcc/testsuite/g++.dg/cpp1z/fold7a.C
new file mode 100644
index 0000000..d56cefb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/fold7a.C
@@ -0,0 +1,5 @@ 
+// This macro should not be defined without -std=c++1z.
+
+#ifdef __cpp_fold_expressions
+#error __cpp_fold_expressions defined
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/utf8-2.C b/gcc/testsuite/g++.dg/cpp1z/utf8-2.C
new file mode 100644
index 0000000..152762f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/utf8-2.C
@@ -0,0 +1,9 @@ 
+// { dg-options "-std=c++1z" }
+
+#ifndef __cpp_unicode_characters
+#error __cpp_unicode_characters not defined
+#endif
+
+#if __cpp_unicode_characters != 201411
+#error Wrong value for __cpp_unicode_characters
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C b/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
new file mode 100644
index 0000000..9985cd0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
@@ -0,0 +1,5 @@ 
+// This macro should not be 201411 without -std=c++1z.
+
+#if __cpp_unicode_characters == 201411
+#error Wrong value for __cpp_unicode_characters
+#endif