From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26504 invoked by alias); 31 May 2014 03:43:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 26494 invoked by uid 89); 31 May 2014 03:43:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: vms173005pub.verizon.net Received: from vms173005pub.verizon.net (HELO vms173005pub.verizon.net) (206.46.173.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 31 May 2014 03:43:13 +0000 Received: from [192.168.1.3] ([unknown] [96.244.82.171]) by vms173005.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0N6F00CST6BY6T90@vms173005.mailsrvcs.net> for gcc-patches@gcc.gnu.org; Fri, 30 May 2014 22:43:11 -0500 (CDT) Message-id: <53894FCF.1000802@verizon.net> Date: Sat, 31 May 2014 03:43:00 -0000 From: Ed Smith-Rowland <3dw4rd@verizon.net> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-version: 1.0 To: gcc-patches , Jason Merrill Subject: [C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite Content-type: multipart/mixed; boundary=------------090804010604030104010606 X-SW-Source: 2014-05/txt/msg02668.txt.bz2 This is a multi-part message in MIME format. --------------090804010604030104010606 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 102 This is the c-family part: Setting the language feature macos and defining the __has_include macro. --------------090804010604030104010606 Content-Type: text/plain; charset=UTF-8; name="CL_feature_test_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_feature_test_2" Content-length: 593 c-family: 2014-05-31 Ed Smith-Rowland <3dw4rd@verizon.net> Implement SD-6: SG10 Feature Test Recommendations * c-cppbuiltin.c (c_cpp_builtins()): Define language feature macros and the __has_header macro. libstdc++: 2014-05-31 Ed Smith-Rowland <3dw4rd@verizon.net> Implement SD-6: SG10 Feature Test Recommendations * g++.dg/cpp1y/feat-cxx11-neg.C: New. * g++.dg/cpp1y/feat-cxx11.C: New. * g++.dg/cpp1y/feat-cxx14-neg.C: New. * g++.dg/cpp1y/feat-cxx14.C: New. * g++.dg/cpp1y/phoobhar.h: New. * g++.dg/cpp1y/testinc/phoobhar.h: New. * g++.dg/cpp1y/testinc/phoobhar.h: New. --------------090804010604030104010606 Content-Type: text/plain; charset=UTF-8; name="patch_feature_test_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_feature_test_2" Content-length: 10519 Index: c-family/c-cppbuiltin.c =================================================================== --- c-family/c-cppbuiltin.c (revision 211078) +++ c-family/c-cppbuiltin.c (working copy) @@ -805,7 +805,43 @@ if (flag_rtti) cpp_define (pfile, "__GXX_RTTI"); if (cxx_dialect >= cxx11) - cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__"); + { + cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__"); + /* Set feature test macros for C++11 */ + cpp_define (pfile, "__has_include(STR)=__has_include__(STR)"); + cpp_define (pfile, + "__has_include_next(STR)=__has_include_next__(STR)"); + + 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"); + } + if (cxx_dialect > cxx11) + { + /* Set feature test macros for C++14 */ + cpp_define (pfile, "__cpp_binary_literals=201304"); + 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_return_type_deduction=201304"); + cpp_define (pfile, "__cpp_runtime_arrays=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. */ Index: testsuite/g++.dg/cpp1y/feat-cxx11-neg.C =================================================================== --- testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (revision 0) +++ testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (working copy) @@ -0,0 +1,35 @@ +// { dg-do compile { target c++11_only } } + +// These *are* defined in C++14 onwards. + +#ifndef __cpp_binary_literals +# error "__cpp_binary_literals" // { dg-error "error" } +#endif + +#ifndef __cpp_init_captures +# error "__cpp_init_captures" // { dg-error "error" } +#endif + +#ifndef __cpp_generic_lambdas +# error "__cpp_generic_lambdas" // { dg-error "error" } +#endif + +#ifndef __cpp_decltype_auto +# error "__cpp_decltype_auto" // { dg-error "error" } +#endif + +#ifndef __cpp_return_type_deduction +# error "__cpp_return_type_deduction" // { dg-error "error" } +#endif + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" // { dg-error "error" } +#endif + +#ifndef __cpp_digit_separators +# error "__cpp_digit_separators" // { dg-error "error" } +#endif + +#ifndef __cpp_attribute_deprecated +# error "__cpp_attribute_deprecated" // { dg-error "error" } +#endif Index: testsuite/g++.dg/cpp1y/feat-cxx11.C =================================================================== --- testsuite/g++.dg/cpp1y/feat-cxx11.C (revision 0) +++ testsuite/g++.dg/cpp1y/feat-cxx11.C (working copy) @@ -0,0 +1,73 @@ +// { dg-do compile { target c++11_only } } + +#ifndef __cpp_unicode_characters +# error "__cpp_unicode_characters" +#elif __cpp_unicode_characters != 200704 +# error "__cpp_unicode_characters != 200704" +#endif + +#ifndef __cpp_raw_strings +# error "__cpp_raw_strings" +#elif __cpp_raw_strings != 200710 +# error "__cpp_raw_strings != 200710" +#endif + +#ifndef __cpp_unicode_literals +# error "__cpp_unicode_literals" +#elif __cpp_unicode_literals != 200710 +# error "__cpp_unicode_literals != 200710" +#endif + +#ifndef __cpp_user_defined_literals +# error "__cpp_user_defined_literals" +#elif __cpp_user_defined_literals != 200809 +# error "__cpp_user_defined_literals != 200809" +#endif + +#ifndef __cpp_lambdas +# error "__cpp_lambdas" +#elif __cpp_lambdas != 200907 +# error "__cpp_lambdas != 200907" +#endif + +#ifndef __cpp_constexpr +# error "__cpp_constexpr" +#elif __cpp_constexpr != 200704 +# error "__cpp_constexpr != 200704" +#endif + +#ifndef __cpp_static_assert +# error "__cpp_static_assert" +#elif __cpp_static_assert != 200410 +# error "__cpp_static_assert != 200410" +#endif + +#ifndef __cpp_decltype +# error "__cpp_decltype" +#elif __cpp_decltype != 200707 +# error "__cpp_decltype != 200707" +#endif + +#ifndef __cpp_attributes +# error "__cpp_attributes" +#elif __cpp_attributes != 200809 +# error "__cpp_attributes != 200809" +#endif + +#ifndef __cpp_rvalue_reference +# error "__cpp_rvalue_reference" +#elif __cpp_rvalue_reference != 200610 +# error "__cpp_rvalue_reference != 200610" +#endif + +#ifndef __cpp_variadic_templates +# error "__cpp_variadic_templates" +#elif __cpp_variadic_templates != 200704 +# error "__cpp_variadic_templates != 200704" +#endif + +#ifndef __cpp_alias_templates +# error "__cpp_alias_templates" +#elif __cpp_alias_templates != 200704 +# error "__cpp_alias_templates != 200704" +#endif Index: testsuite/g++.dg/cpp1y/feat-cxx14-neg.C =================================================================== --- testsuite/g++.dg/cpp1y/feat-cxx14-neg.C (revision 0) +++ testsuite/g++.dg/cpp1y/feat-cxx14-neg.C (working copy) @@ -0,0 +1,7 @@ +// { dg-do compile { target c++1y } } + +#ifndef __cpp_constexpr +# error "__cpp_constexpr" +#elif __cpp_constexpr != 200704 +# error "__cpp_constexpr" // { dg-error "error" } +#endif Index: testsuite/g++.dg/cpp1y/feat-cxx14.C =================================================================== --- testsuite/g++.dg/cpp1y/feat-cxx14.C (revision 0) +++ testsuite/g++.dg/cpp1y/feat-cxx14.C (working copy) @@ -0,0 +1,186 @@ +// { dg-do compile { target c++1y } } +// { dg-options "-I. -Itestinc" } + +// Begin C++11 tests. + +#ifndef __cpp_unicode_characters +# error "__cpp_unicode_characters" +#endif + +#ifndef __cpp_raw_strings +# error "__cpp_raw_strings" +#endif + +#ifndef __cpp_unicode_literals +# error "__cpp_unicode_literals" +#endif + +#ifndef __cpp_user_defined_literals +# error "__cpp_user_defined_literals" +#endif + +#ifndef __cpp_lambdas +# error "__cpp_lambdas" +#endif + +#ifndef __cpp_constexpr +# error "__cpp_constexpr" +#endif + +#ifndef __cpp_static_assert +# error "__cpp_static_assert" +#endif + +#ifndef __cpp_decltype +# error "__cpp_decltype" +#endif + +#ifndef __cpp_attributes +# error "__cpp_attributes" +#endif + +#ifndef __cpp_rvalue_reference +# error "__cpp_rvalue_reference" +#endif + +#ifndef __cpp_variadic_templates +# error "__cpp_variadic_templates" +#endif + +// Begin C++14 tests. + +#ifndef __cpp_binary_literals +# error "__cpp_binary_literals" +#endif + +#ifndef __cpp_init_captures +# error "__cpp_init_captures" +#endif + +#ifndef __cpp_generic_lambdas +# error "__cpp_generic_lambdas" +#endif + +#ifdef __cpp_constexpr +# if __cpp_constexpr < 201304 +# error "__cpp_constexpr" +# endif +#endif + +#ifndef __cpp_decltype_auto +# error "__cpp_decltype_auto" +#endif + +#ifndef __cpp_return_type_deduction +# error "__cpp_return_type_deduction" +#endif + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#endif + +// Aggregate initializers not in yet. +#ifdef __cpp_aggregate_nsdmi +# error "__cpp_aggregate_nsdmi" +#endif + +// Variable templates not in yet. +#ifdef __cpp_variable_templates +# error "__cpp_variable_templates" +#endif + +#ifndef __cpp_digit_separators +# error "__cpp_digit_separators" +#endif + +#ifndef __cpp_attribute_deprecated +# error "__cpp_attribute_deprecated" +#endif + +// Sized deallocation not in yet. +#ifdef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" +#endif + +// Begin include checks. + +// Check for __has_include macro. +#ifndef __has_include +# error "__has_include" +#endif + +// Quoted complex.h should find at least the bracket version (use operator). +#if __has_include__ "complex.h" +#else +# error "complex.h" +#endif + +// Try known bracket header (use operator). +#if __has_include__() +#else +# error "" +#endif + +// Define and use a macro to invoke the operator. +#define sluggo(TXT) __has_include__(TXT) + +#if sluggo() +#else +# error "" +#endif + +#if ! sluggo() +# error "" +#else +#endif + +// Quoted complex.h should find at least the bracket version. +#if __has_include("complex.h") +#else +# error "complex.h" +#endif + +// Try known local quote header. +#if __has_include("complex_literals.h") +#else +# error "\"complex_literals.h\"" +#endif + +// Try nonexistent bracket header. +#if __has_include() +# error "" +#else +#endif + +// Try nonexistent quote header. +#if __has_include("phlegm") +# error "\"phlegm\"" +#else +#endif + +// Test __has_include_next. +#if __has_include("phoobhar.h") +# include "phoobhar.h" +#else +# error "phoobhar.h" +#endif + +// Try a macro. +#define COMPLEX_INC "complex.h" +#if __has_include(COMPLEX_INC) +#else +# error COMPLEX_INC +#endif + +// Realistic use of __has_include. +#if __has_include() +# define STD_ARRAY 1 +# include + template + using array = std::array<_Tp, _Num>; +#elif __has_include() +# define TR1_ARRAY 1 +# include + template + typedef std::tr1::array<_Tp, _Num> array; +#endif Index: testsuite/g++.dg/cpp1y/phoobhar.h =================================================================== --- testsuite/g++.dg/cpp1y/phoobhar.h (revision 0) +++ testsuite/g++.dg/cpp1y/phoobhar.h (working copy) @@ -0,0 +1,16 @@ + +int +phoo(); + +int +bhar(); + +#ifndef __has_include_next +# error "__has_include_next" +#else +# if __has_include_next("phoobhar.h") +# include_next "phoobhar.h" +# else +# error "phoobhar.h" +# endif +#endif Index: testsuite/g++.dg/cpp1y/testinc/phoobhar.h =================================================================== Index: testsuite/g++.dg/cpp1y/testinc/phoobhar.h =================================================================== --------------090804010604030104010606--