From patchwork Thu Nov 4 05:30:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Kosnik X-Patchwork-Id: 70099 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 BF61DB6EE9 for ; Thu, 4 Nov 2010 16:31:16 +1100 (EST) Received: (qmail 12285 invoked by alias); 4 Nov 2010 05:31:09 -0000 Received: (qmail 12260 invoked by uid 22791); 4 Nov 2010 05:31:06 -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; Thu, 04 Nov 2010 05:30:59 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA45Uv6M012110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Nov 2010 01:30:58 -0400 Received: from shotwell ([10.3.113.8]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA45UvFZ029498; Thu, 4 Nov 2010 01:30:57 -0400 Date: Wed, 3 Nov 2010 22:30:56 -0700 From: Benjamin Kosnik To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [v3] constexpr tests, default ctors Message-ID: <20101103223056.495824e9@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 Adds in tuple default constexpr ctors, tests. Adds in initializer_list tests. Remaining are the shared/unique/weak_ptr classes, passing that off to Jonathan... tested x86_64/linux -benjamin 2010-11-02 Benjamin Kosnik * include/std/tuple (tuple): Make default constructors constexpr. * testsuite/20_util/tuple/cons/constexpr.cc: Add. * testsuite/18_support/initializer_list/requirements/ constexpr_functions.cc: Add. * testsuite/18_support/initializer_list/constexpr.cc: Add. Index: include/std/tuple =================================================================== --- include/std/tuple (revision 166298) +++ include/std/tuple (working copy) @@ -64,7 +64,7 @@ struct _Head_base<_Idx, _Head, true> : public _Head { - _Head_base() + constexpr _Head_base() : _Head() { } _Head_base(const _Head& __h) @@ -83,7 +83,7 @@ template struct _Head_base<_Idx, _Head, false> { - _Head_base() + constexpr _Head_base() : _M_head_impl() { } _Head_base(const _Head& __h) @@ -147,7 +147,7 @@ _Inherited& _M_tail() { return *this; } const _Inherited& _M_tail() const { return *this; } - _Tuple_impl() + constexpr _Tuple_impl() : _Inherited(), _Base() { } explicit @@ -225,7 +225,7 @@ typedef _Tuple_impl<0, _Elements...> _Inherited; public: - _GLIBCXX_CONSTEXPR tuple() + constexpr tuple() : _Inherited() { } explicit @@ -310,7 +310,7 @@ typedef _Tuple_impl<0, _T1, _T2> _Inherited; public: - tuple() + constexpr tuple() : _Inherited() { } explicit @@ -408,7 +408,7 @@ typedef _Tuple_impl<0, _T1> _Inherited; public: - tuple() + constexpr tuple() : _Inherited() { } explicit Index: testsuite/18_support/initializer_list/requirements/constexpr_functions.cc =================================================================== --- testsuite/18_support/initializer_list/requirements/constexpr_functions.cc (revision 0) +++ testsuite/18_support/initializer_list/requirements/constexpr_functions.cc (revision 0) @@ -0,0 +1,57 @@ +// { 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_functions + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr _Ttesttype obj; + constexpr auto v4 __attribute__((unused)) + = obj.size(); + constexpr auto v5 __attribute__((unused)) + = obj.begin(); + constexpr auto v6 __attribute__((unused)) + = obj.end(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()>(); + return 0; +} Index: testsuite/18_support/initializer_list/constexpr.cc =================================================================== --- testsuite/18_support/initializer_list/constexpr.cc (revision 0) +++ testsuite/18_support/initializer_list/constexpr.cc (revision 0) @@ -0,0 +1,30 @@ +// { 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 + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + + return 0; +} Index: testsuite/20_util/tuple/cons/constexpr.cc =================================================================== --- testsuite/20_util/tuple/cons/constexpr.cc (revision 0) +++ testsuite/20_util/tuple/cons/constexpr.cc (revision 0) @@ -0,0 +1,29 @@ +// { 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 + +int main() +{ + __gnu_test::constexpr_default_constructible test; + test.operator()>(); + return 0; +}