From patchwork Fri Nov 5 22:50:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Kosnik X-Patchwork-Id: 70307 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]) by ozlabs.org (Postfix) with SMTP id D1ED01007D2 for ; Sat, 6 Nov 2010 09:50:21 +1100 (EST) Received: (qmail 3416 invoked by alias); 5 Nov 2010 22:50:20 -0000 Received: (qmail 3319 invoked by uid 22791); 5 Nov 2010 22:50:17 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 05 Nov 2010 22:50:09 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA5Mo8Sw027639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2010 18:50:08 -0400 Received: from shotwell ([10.3.113.8]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA5Mo7ID013743; Fri, 5 Nov 2010 18:50:07 -0400 Date: Fri, 5 Nov 2010 15:50:06 -0700 From: Benjamin Kosnik To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [v3] is_literal_type tests Message-ID: <20101105155006.103e19a0@shotwell> Mime-Version: 1.0 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 Adjust doxygen files for the tr1_impl removal. Adds test for integral_constant. Adds tests for std::is_literal_type. Of note on this is the divergence with is_literal_type and 3.9p10. As per: struct NLType // not literal type? { int _M_i; NLType() : _M_i(0) { } constexpr NLType(int __i) : _M_i(__i) { } NLType(const NLType& __other) : _M_i(__other._M_i) { } }; This is a literal_type as per std::is_literal_type, even with non-trivial default constructor and copy constructors that via 3.9p10 would be expected to fail. tested x86_64/linux -benjamin 2010-11-05 Benjamin Kosnik * doc/doxygen/user.cfg.in: Remove tr1_impl headers. * testsuite/tr1/4_metaprogramming/integral_constant/requirements/ constexpr_data.cc: New. * testsuite/util/testsuite_tr1.h (LType, LTypeDerived, NLType): New. * testsuite/20_util/is_literal_type/value.cc: New. * testsuite/20_util/is_literal_type/requirements/typedefs.cc: Name. * testsuite/20_util/is_literal_type/requirements/ explicit_instantiation.cc: New. Index: doc/doxygen/user.cfg.in =================================================================== --- doc/doxygen/user.cfg.in (revision 166379) +++ doc/doxygen/user.cfg.in (working copy) @@ -586,6 +586,7 @@ @srcdir@/libsupc++/cxxabi.h \ @srcdir@/libsupc++/cxxabi-forced.h \ @srcdir@/libsupc++/exception \ + @srcdir@/libsupc++/exception_defines.h \ @srcdir@/libsupc++/exception_ptr.h \ @srcdir@/libsupc++/initializer_list \ @srcdir@/libsupc++/nested_exception.h \ @@ -665,6 +666,7 @@ include/backward/strstream \ include/debug/bitset \ include/debug/deque \ + include/debug/forward_list \ include/debug/list \ include/debug/map \ include/debug/set \ @@ -674,6 +676,7 @@ include/debug/vector \ include/profile/bitset \ include/profile/deque \ + include/profile/forward_list \ include/profile/list \ include/profile/map \ include/profile/set \ @@ -707,20 +710,6 @@ include/tr1/ctime \ include/tr1/cwchar \ include/tr1/cwctype \ - include/tr1_impl/array \ - include/tr1_impl/cctype \ - include/tr1_impl/cfenv \ - include/tr1_impl/cinttypes \ - include/tr1_impl/cmath \ - include/tr1_impl/complex \ - include/tr1_impl/cstdint \ - include/tr1_impl/cstdio \ - include/tr1_impl/cstdlib \ - include/tr1_impl/cwchar \ - include/tr1_impl/cwctype \ - include/tr1_impl/type_traits \ - include/tr1_impl/utility \ - include/tr1_impl \ include/decimal/decimal \ include/ \ include/@host_alias@/bits \ @@ -728,6 +717,7 @@ include/bits \ include/debug \ include/parallel \ + include/precompiled \ include/profile \ include/profile/impl \ include/ext \ Index: testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc =================================================================== --- testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc (revision 0) +++ testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc (revision 0) @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 + +namespace __gnu_test +{ + struct constexpr_member_data + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v __attribute__((unused)) (_Ttesttype::value); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()>(); + test.operator()>(); + return 0; +} Index: testsuite/util/testsuite_tr1.h =================================================================== --- testsuite/util/testsuite_tr1.h (revision 166379) +++ testsuite/util/testsuite_tr1.h (working copy) @@ -57,7 +57,7 @@ // For testing tr1/type_traits/extent, which has a second template // parameter. template class Property, - typename Type, unsigned Uint> + typename Type, unsigned Uint> bool test_property(typename Property::value_type value) { @@ -80,7 +80,7 @@ #endif template class Relationship, - typename Type1, typename Type2> + typename Type1, typename Type2> bool test_relationship(bool value) { @@ -188,6 +188,33 @@ int j; }; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + struct LType // literal type + { + int _M_i; + + constexpr LType(int __i) : _M_i(__i) { } + }; + + struct LTypeDerived : public LType + { + constexpr LTypeDerived(int __i) : LType(__i) { } + }; + + struct NLType // not literal type + { + int _M_i; + + NLType() : _M_i(0) { } + + constexpr NLType(int __i) : _M_i(__i) { } + + NLType(const NLType& __other) : _M_i(__other._M_i) { } + + ~NLType() { _M_i = 0; } + }; +#endif + int truncate_float(float x) { return (int)x; } long truncate_double(double x) { return (long)x; } @@ -251,7 +278,7 @@ // For use in 8_c_compatibility. template - typename __gnu_cxx::__enable_if::__value, + typename __gnu_cxx::__enable_if::__value, bool>::__type check_ret_type(T) { return true; } Index: testsuite/20_util/is_literal_type/value.cc =================================================================== --- testsuite/20_util/is_literal_type/value.cc (revision 0) +++ testsuite/20_util/is_literal_type/value.cc (revision 0) @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini +// +// Copyright (C) 2010 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_literal_type; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/20_util/is_literal_type/requirements/typedefs.cc =================================================================== --- testsuite/20_util/is_literal_type/requirements/typedefs.cc (revision 0) +++ testsuite/20_util/is_literal_type/requirements/typedefs.cc (revision 0) @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini +// +// Copyright (C) 2010 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_literal_type 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_literal_type/requirements/explicit_instantiation.cc =================================================================== --- testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc (revision 0) +++ testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc (revision 0) @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini + +// Copyright (C) 2010 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_literal_type; +}