From patchwork Thu May 2 12:04:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 240948 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 DD28D2C00D1 for ; Thu, 2 May 2013 22:05:49 +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=QGbbViTFso8HbtN3ClhaCeb8xNSLdDAS4lkgkGKhG/r GhJmJh9p1jdD19bKA2uSpU3RJpIU6sCKYPj7DZ6K8IUoo2aQ1ZjE3+SZVVyQTmTM UNN1oSt4OytkrbtCw9HbIbrSA9b3ZhStDbv44cA6ROLMEf6tJqC2+ew2+rZwGmeU = 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=Csb2Y9+ArPvfETM2TmVXaAiLqtw=; b=oKnqNt+0rHEAbC/z5 6Y/frbwXFEoOGVOe9Iuxl3SracKsoT66HlBiC8G6q+ti75zc3GmXt7OXJoHhgvUQ yEjaBwn8msiG9S2C9mR4GlVNRbJTimE6ofW4K6VhX9QorNEW14PdTQCZ74N7Imte 5Sj5dhrgS7qi/p9pl54bRMQ/lw= Received: (qmail 19615 invoked by alias); 2 May 2013 12:04:40 -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 19568 invoked by uid 89); 2 May 2013 12:04:39 -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 12:04:37 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r42C4YEj020841 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 May 2013 12:04:35 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r42C4XYP008287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 2 May 2013 12:04:34 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r42C4XCw014154; Thu, 2 May 2013 12:04:33 GMT Received: from poldo4.casa (/79.17.190.68) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 May 2013 05:04:33 -0700 Message-ID: <5182564F.4020007@oracle.com> Date: Thu, 02 May 2013 14:04:31 +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 some tests for std::integral_constant X-Virus-Found: No Hi, committed to mainline. Thanks, Paolo. /////////////////////// Index: testsuite/20_util/integral_constant/operator_value_type.cc =================================================================== --- testsuite/20_util/integral_constant/operator_value_type.cc (revision 0) +++ testsuite/20_util/integral_constant/operator_value_type.cc (working copy) @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// +// 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 //testsuite_hooks.h> + +typedef std::integral_constant ic_one; +typedef std::integral_constant ic_zero; +typedef std::integral_constant ic_minus_one; + +typedef std::integral_constant ic_true; +typedef std::integral_constant ic_false; + +static_assert( ic_one() == 1, "" ); +static_assert( ic_zero() == 0, "" ); +static_assert( ic_minus_one() == -1, "" ); + +static_assert( ic_true() == true, "" ); +static_assert( ic_false() == false, "" ); Index: testsuite/20_util/integral_constant/requirements/constexpr_data.cc =================================================================== --- testsuite/20_util/integral_constant/requirements/constexpr_data.cc (revision 0) +++ testsuite/20_util/integral_constant/requirements/constexpr_data.cc (working copy) @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// 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 + +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/20_util/integral_constant/requirements/explicit_instantiation.cc =================================================================== --- testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc (revision 0) +++ testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc (working copy) @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 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 integral_constant; +} Index: testsuite/20_util/integral_constant/requirements/typedefs.cc =================================================================== --- testsuite/20_util/integral_constant/requirements/typedefs.cc (revision 0) +++ testsuite/20_util/integral_constant/requirements/typedefs.cc (working copy) @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++11" } +// +// 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::integral_constant 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/integral_constant/static_definition.cc =================================================================== --- testsuite/20_util/integral_constant/static_definition.cc (revision 0) +++ testsuite/20_util/integral_constant/static_definition.cc (working copy) @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// +// 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 + +void test01() +{ + bool test __attribute__((unused)) = true; + const bool* p = &std::integral_constant::value; + VERIFY( p ); +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/20_util/integral_constant/true_false_type_typedefs.cc =================================================================== --- testsuite/20_util/integral_constant/true_false_type_typedefs.cc (revision 0) +++ testsuite/20_util/integral_constant/true_false_type_typedefs.cc (working copy) @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11" } +// +// 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::true_type true_type; + typedef std::false_type false_type; + + typedef true_type::value_type true_value_type; + typedef true_type::type true_type; + typedef true_type::type::value_type true_type_value_type; + typedef true_type::type::type true_type_type; + + typedef false_type::value_type false_value_type; + typedef false_type::type false_type; + typedef false_type::type::value_type false_type_value_type; + typedef false_type::type::type false_type_type; +} Index: testsuite/20_util/integral_constant/true_false_value.cc =================================================================== --- testsuite/20_util/integral_constant/true_false_value.cc (revision 0) +++ testsuite/20_util/integral_constant/true_false_value.cc (working copy) @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } +// +// 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 + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::true_type; + using std::false_type; + + static_assert( true_type::value == true, "" ); + static_assert( false_type::value == false, "" ); + static_assert( true_type::type::value == true, "" ); + static_assert( false_type::type::value == false, "" ); + + VERIFY( true_type::value == true ); + VERIFY( false_type::value == false ); + VERIFY( true_type::type::value == true ); + VERIFY( false_type::type::value == false ); +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc =================================================================== --- testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc (revision 198511) +++ testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc (working copy) @@ -1,52 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++0x" } - -// Copyright (C) 2010-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 - -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; -}