From patchwork Thu May 2 10:17:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 240931 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 637E92C00D3 for ; Thu, 2 May 2013 20:17:26 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=fBQSgnYPEoUaq4YsQ2v9kFEx2klWZJh8rkN1YAfkkNK SHeTwD2UptDLIuYQ6QudjO/PxPIF73FgmFAKSl5V3sJzhMS4MyK256VFexMoCzYT K3kR9a/ThGEuoE+PliLEv0Q98eOWqFLUivRReuVchzhzxjPmrXJvtYL8+xKWihmQ = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=ds9DrGXI9p59cZiFwvQfY4Wd8SI=; b=Tr4B0l/u9puIYtLtE 1WrP7rQ02MlvCBOaFCvInvEOATxSPW6+tzmlmM/NVlv5W7B7JburHxWHALdeCN8Y dtM0FA08ZoBCjvCGONAql8tGQHmfb7hFqMj2RG4FeHtvCgEWl4azC+q4DKajYaVM qdxZ5A3dTdhAtRLDS0jGBajaw4= Received: (qmail 8318 invoked by alias); 2 May 2013 10:17: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 8300 invoked by uid 89); 2 May 2013 10:17:19 -0000 X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 02 May 2013 10:17:17 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r42AHESr007873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 May 2013 10:17:15 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r42AHD6M021507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 2 May 2013 10:17:14 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r42AHCkC011963; Thu, 2 May 2013 10:17:13 GMT Received: from poldo4.casa (/79.17.190.68) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 May 2013 03:17:12 -0700 Message-ID: <51823D26.7030208@oracle.com> Date: Thu, 02 May 2013 12:17:10 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Add std::is_null_pointer X-Virus-Found: No Hi, this adds the trait per LWG 2247 [Ready]. For the time being I'm keeping __is_nullptr_t, which maybe somebody was using as an extension... Tested x86_64-linux. Thanks, Paolo. ///////////////////////////// 2013-05-02 Paolo Carlini * include/std/type_traits (is_null_pointer): Add. (__is_nullptr_t): Implement in terms of the latter. (is_fundamental, is_scalar): Adjust. * testsuite/20_util/is_null_pointer/requirements/ explicit_instantiation.cc: New. * testsuite/20_util/is_null_pointer/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_null_pointer/value.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line number. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. Index: include/std/type_traits =================================================================== --- include/std/type_traits (revision 198511) +++ include/std/type_traits (working copy) @@ -402,17 +402,23 @@ : public true_type { }; template - struct __is_nullptr_t_helper + struct __is_null_pointer_helper : public false_type { }; template<> - struct __is_nullptr_t_helper + struct __is_null_pointer_helper : public true_type { }; + // is_null_pointer (LWG 2247). + template + struct is_null_pointer + : public __is_null_pointer_helper::type>::type + { }; + // __is_nullptr_t (extension). template struct __is_nullptr_t - : public __is_nullptr_t_helper::type>::type + : public is_null_pointer<_Tp> { }; // Composite type categories. @@ -433,7 +439,8 @@ /// is_fundamental template struct is_fundamental - : public __or_, is_void<_Tp>, __is_nullptr_t<_Tp>>::type + : public __or_, is_void<_Tp>, + is_null_pointer<_Tp>>::type { }; /// is_object @@ -450,7 +457,7 @@ template struct is_scalar : public __or_, is_enum<_Tp>, is_pointer<_Tp>, - is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type + is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type { }; /// is_compound Index: testsuite/20_util/declval/requirements/1_neg.cc =================================================================== --- testsuite/20_util/declval/requirements/1_neg.cc (revision 198511) +++ testsuite/20_util/declval/requirements/1_neg.cc (working copy) @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 1852 } +// { dg-error "static assertion failed" "" { target *-*-* } 1859 } #include Index: testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc =================================================================== --- testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc (revision 0) +++ testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc (working copy) @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// 2013-05-02 Paolo Carlini + +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_null_pointer; +} Index: testsuite/20_util/is_null_pointer/requirements/typedefs.cc =================================================================== --- testsuite/20_util/is_null_pointer/requirements/typedefs.cc (revision 0) +++ testsuite/20_util/is_null_pointer/requirements/typedefs.cc (working copy) @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// 2013-05-02 Paolo Carlini +// +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_null_pointer test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} Index: testsuite/20_util/is_null_pointer/value.cc =================================================================== --- testsuite/20_util/is_null_pointer/value.cc (revision 0) +++ testsuite/20_util/is_null_pointer/value.cc (working copy) @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++11" } +// 2013-05-02 Paolo Carlini +// +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_null_pointer; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/20_util/make_signed/requirements/typedefs_neg.cc =================================================================== --- testsuite/20_util/make_signed/requirements/typedefs_neg.cc (revision 198511) +++ testsuite/20_util/make_signed/requirements/typedefs_neg.cc (working copy) @@ -48,5 +48,5 @@ // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1594 } -// { dg-error "declaration of" "" { target *-*-* } 1558 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1601 } +// { dg-error "declaration of" "" { target *-*-* } 1565 } Index: testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc =================================================================== --- testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc (revision 198511) +++ testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc (working copy) @@ -48,5 +48,5 @@ // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1512 } -// { dg-error "declaration of" "" { target *-*-* } 1476 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1519 } +// { dg-error "declaration of" "" { target *-*-* } 1483 }