Re: [PATCH C++] - SD-6 Implementation Part 2 - __has_include macro and C++ language feature macros.

2014-09-26 Thread Ed Smith-Rowland

On 09/25/2014 01:40 PM, Jason Merrill wrote:

On 09/01/2014 09:41 PM, Ed Smith-Rowland wrote:

+  cpp_define (pfile, __cpp_attribute_deprecated=201309);


Don't we support attribute deprecated in C++11?

Jason



We support [[gnu::deprecated]] in C++11 bit not [[deprecated]] until C++14.
Ed



Re: [PATCH C++] - SD-6 Implementation Part 2 - __has_include macro and C++ language feature macros.

2014-09-26 Thread Jason Merrill

On 09/26/2014 10:20 AM, Ed Smith-Rowland wrote:

On 09/25/2014 01:40 PM, Jason Merrill wrote:

Don't we support attribute deprecated in C++11?


We support [[gnu::deprecated]] in C++11 bit not [[deprecated]] until C++14.


Hmm, that seems unnecessary.  I'd allow it in C++11 as well, and *maybe* 
complain if -pedantic; 7.6/5 says For an attribute-token not specified 
in this International Standard, the behavior is implementation defined 
so allowing it is conforming.


Jason



Re: [PATCH C++] - SD-6 Implementation Part 2 - __has_include macro and C++ language feature macros.

2014-09-25 Thread Jason Merrill

On 09/01/2014 09:41 PM, Ed Smith-Rowland wrote:

+ /* Return type deduction was added as an extension to C++11
+and was standardized for C+14.  */
+ cpp_define (pfile, __cpp_return_type_deduction=201304);


When I try to use it with -std=c++11 I get

wa.C:1:8: error: ‘f’ function uses ‘auto’ type specifier without 
trailing return type

 auto f() { return 42; }
^
wa.C:1:8: note: deduced return type only available with -std=c++14 or 
-std=gnu++14


Let's move it to the C++14 section.


There is one bit: arrays of runtime bound.  These got kicked out of C++14 I 
think and is languishing in a TS.
OTOH, we still support it.  It's better than the C99 version we supported.
What direction should I take?
/*  Runtime sized arrays
+have C++14 semantics even for C++98.  */


The comment is inaccurate; most of the restrictions on arrays of runtime 
bound are only applied in C++14 mode.  Let's put this macro in the C++14 
section as well until there's a value or separate macro indicating C99 
VLA support.


Jason



Re: [PATCH C++] - SD-6 Implementation Part 2 - __has_include macro and C++ language feature macros.

2014-09-25 Thread Jason Merrill

On 09/01/2014 09:41 PM, Ed Smith-Rowland wrote:

+ cpp_define (pfile, __cpp_attribute_deprecated=201309);


Don't we support attribute deprecated in C++11?

Jason



[PATCH C++] - SD-6 Implementation Part 2 - __has_include macro and C++ language feature macros.

2014-09-01 Thread Ed Smith-Rowland

Greetings,

I am finally getting back to my SD-6 C++ features test work.

This second part adds a __has_include function-like macro that will 
return true if a header exists. I also added a __has_include_next 
function-like macro as an extension. Clang has this extension.

These macros just wrap the built-ins introduced in the previous patch.

As requested by folk I have rearranged which language-feature macros are 
available with what .

There is one bit: arrays of runtime bound.  These got kicked out of C++14 I 
think and is languishing in a TS.
OTOH, we still support it.  It's better than the C99 version we supported.
What direction should I take?

Bootstrapped and tested under x86_64-linux.

OK?

Ed

2014-09-02  Edward Smith-Rowland  3dw...@verizon.net

Implement SD-6: SG10 Feature Test Recommendations
* c-cppbuiltin.c (c_cpp_builtins()): Define language feature
macros and the __has_header macro.

Index: c-cppbuiltin.c
===
--- c-cppbuiltin.c  (revision 214680)
+++ c-cppbuiltin.c  (working copy)
@@ -794,6 +794,12 @@
   /* For stddef.h.  They require macros defined in c-common.c.  */
   c_stddef_cpp_builtins ();
 
+  /* Set include test macros for all C/C++ (not for just C++11 etc.)
+ the builtins __has_include__ and __has_include_next__ are defined
+ in libcpp.  */
+  cpp_define (pfile, __has_include(STR)=__has_include__(STR));
+  cpp_define (pfile, __has_include_next(STR)=__has_include_next__(STR));
+
   if (c_dialect_cxx ())
 {
   if (flag_weak  SUPPORTS_ONE_ONLY)
@@ -800,12 +806,57 @@
cpp_define (pfile, __GXX_WEAK__=1);
   else
cpp_define (pfile, __GXX_WEAK__=0);
+
   if (warn_deprecated)
cpp_define (pfile, __DEPRECATED);
+
   if (flag_rtti)
cpp_define (pfile, __GXX_RTTI);
+
   if (cxx_dialect = cxx11)
 cpp_define (pfile, __GXX_EXPERIMENTAL_CXX0X__);
+
+  /* Binary literals and variable length arrays have been allowed in g++
+before C++11 and were standardized for C++14.  Runtime sized arrays
+have C++14 semantics even for C++98.  */
+  if (!pedantic || cxx_dialect  cxx11)
+   {
+ cpp_define (pfile, __cpp_binary_literals=201304);
+ cpp_define (pfile, __cpp_runtime_arrays=201304);
+   }
+  if (cxx_dialect = cxx11)
+   {
+ /* Set feature test macros for C++11  */
+ 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);
+ cpp_define (pfile, __cpp_lambdas=200907);
+ cpp_define (pfile, __cpp_constexpr=200704);
+ cpp_define (pfile, __cpp_static_assert=200410);
+ cpp_define (pfile, __cpp_decltype=200707);
+ cpp_define (pfile, __cpp_attributes=200809);
+ cpp_define (pfile, __cpp_rvalue_reference=200610);
+ cpp_define (pfile, __cpp_variadic_templates=200704);
+ cpp_define (pfile, __cpp_alias_templates=200704);
+ /* Return type deduction was added as an extension to C++11
+and was standardized for C+14.  */
+ cpp_define (pfile, __cpp_return_type_deduction=201304);
+   }
+  if (cxx_dialect  cxx11)
+   {
+ /* Set feature test macros for C++14  */
+ cpp_define (pfile, __cpp_init_captures=201304);
+ cpp_define (pfile, __cpp_generic_lambdas=201304);
+ //cpp_undef (pfile, __cpp_constexpr);
+ //cpp_define (pfile, __cpp_constexpr=201304);
+ cpp_define (pfile, __cpp_decltype_auto=201304);
+ //cpp_define (pfile, __cpp_aggregate_nsdmi=201304);
+ cpp_define (pfile, __cpp_variable_templates=201304);
+ cpp_define (pfile, __cpp_digit_separators=201309);
+ cpp_define (pfile, __cpp_attribute_deprecated=201309);
+ //cpp_define (pfile, __cpp_sized_deallocation=201309);
+   }
 }
   /* Note that we define this for C as well, so that we know if
  __attribute__((cleanup)) will interface with EH.  */