From patchwork Tue Aug 18 12:54:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 508297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5FA2D1402B5 for ; Tue, 18 Aug 2015 22:54:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Vp8yCgBm; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=fjYKZa+1SqGgBhsYcXwrgkFvBx6jV9pKksx+fJhKCL8KV5efDr UzuhNHx3gVqP82tHhdHFPcLYTZlxGJWw6vqJv+zSIvWudLWYW53HEq+30/CDkR9m u6gjbdNqdtKw2FHeNFce/m9aLPRqbIetZopzj4+B8/5puKrp/rX26uBAw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=p1CU0o7g8U9Un/OCZZr+sK/weLU=; b=Vp8yCgBmQXT/avIqGkOO j4/TXbvJXayxUZxM4jFuu6BFhxa88plhRIgVOi9VcHL9C3yawJ5LoYmodg4b7RQ8 eGc93QFAx7QbuyRpDL0XCHgis9NmWbfUubVcbHeXKLqburmPZZPppoPZvud7oZoj CUJ8M5CWC8voZ6SOskbWvrU= Received: (qmail 75285 invoked by alias); 18 Aug 2015 12:54:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 75271 invoked by uid 89); 18 Aug 2015 12:54:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 18 Aug 2015 12:54:15 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t7ICsD2S002415 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Aug 2015 12:54:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t7ICsD92026095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 18 Aug 2015 12:54:13 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t7ICsCIF004608; Tue, 18 Aug 2015 12:54:12 GMT Received: from [192.168.1.4] (/79.37.218.190) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 18 Aug 2015 05:54:12 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 67160 ("static_assert feature test macro") Message-ID: <55D32AF2.1040503@oracle.com> Date: Tue, 18 Aug 2015 14:54:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, submitter noticed that we have the extended static_assert but the value of the feature macro is still unconditionally 200410, whereas, eg, http://wg21.link/n4440#recs.cpp17 , has 201411. Submitter proposes to unconditionally, thus in c++11 and c++14 modes too, bump the value, but thinking more about the issue, I guess we want that only in c++1z, the only mode which doesn't trigger a pedwarn for those extended features, consistently, with eg, __cpp_init_captures which is defined only in c++14 and and c++1z but only triggers a pedwarn in c++11. Thus a slightly larger patch. Tested x86_64-linux. Thanks, Paolo. ///////////////////// c-family/ 2015-08-18 Paolo Carlini PR c++/67160 * c-cppbuiltin.c (c_cpp_builtins): Fix __cpp_static_assert value in c++1z mode. testsuite/ 2015-08-18 Paolo Carlini PR c++/67160 * g++.dg/cpp1z/feat-cxx1z.C: New. Index: c-family/c-cppbuiltin.c =================================================================== --- c-family/c-cppbuiltin.c (revision 226966) +++ c-family/c-cppbuiltin.c (working copy) @@ -832,7 +832,7 @@ c_cpp_builtins (cpp_reader *pfile) if (cxx_dialect >= cxx11) { - /* Set feature test macros for C++11 */ + /* 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"); @@ -841,7 +841,8 @@ c_cpp_builtins (cpp_reader *pfile) if (cxx_dialect == cxx11) cpp_define (pfile, "__cpp_constexpr=200704"); cpp_define (pfile, "__cpp_range_based_for=200907"); - cpp_define (pfile, "__cpp_static_assert=200410"); + if (cxx_dialect <= cxx14) + 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"); @@ -855,7 +856,7 @@ c_cpp_builtins (cpp_reader *pfile) } if (cxx_dialect > cxx11) { - /* Set feature test macros for C++14 */ + /* Set feature test macros for C++14. */ cpp_define (pfile, "__cpp_return_type_deduction=201304"); cpp_define (pfile, "__cpp_init_captures=201304"); cpp_define (pfile, "__cpp_generic_lambdas=201304"); @@ -865,6 +866,11 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_variable_templates=201304"); cpp_define (pfile, "__cpp_digit_separators=201309"); } + if (cxx_dialect > cxx14) + { + /* Set feature test macros for C++1z. */ + cpp_define (pfile, "__cpp_static_assert=201411"); + } if (flag_concepts) /* Use a value smaller than the 201507 specified in the TS, since we don't yet support extended auto. */ Index: testsuite/g++.dg/cpp1z/feat-cxx1z.C =================================================================== --- testsuite/g++.dg/cpp1z/feat-cxx1z.C (revision 0) +++ testsuite/g++.dg/cpp1z/feat-cxx1z.C (working copy) @@ -0,0 +1,7 @@ +// { dg-do compile { target c++1z } } + +#ifndef __cpp_static_assert +# error "__cpp_static_assert" +#elif __cpp_static_assert != 201411 +# error "__cpp_static_assert != 201411" +#endif