From patchwork Sat Nov 6 03:50:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Kosnik X-Patchwork-Id: 70320 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 3C8E21007D1 for ; Sat, 6 Nov 2010 14:50:31 +1100 (EST) Received: (qmail 29351 invoked by alias); 6 Nov 2010 03:50:29 -0000 Received: (qmail 29335 invoked by uid 22791); 6 Nov 2010 03:50:28 -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; Sat, 06 Nov 2010 03:50:21 +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 oA63oJZj025296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2010 23:50:20 -0400 Received: from shotwell (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA63oI91017839; Fri, 5 Nov 2010 23:50:18 -0400 Date: Fri, 5 Nov 2010 20:50:18 -0700 From: Benjamin Kosnik To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [v3] constexpr comparison operator tests Message-ID: <20101105205018.0f645f60@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 Add typeindex for doxyen. This adds some test infrastructure for detecting comparison operators. tested x86_64/linux -benjamin 2010-11-05 Benjamin Kosnik * doc/doxygen/user.cfg.in: Add typeindex. * testsuite/util/testsuite_common_types.h (constexpr_comparison_eq_ne, constexpr_comparison_operators): New. * testsuite/20_util/duration/comparisons: Move... * testsuite/20_util/duration/comparison_operators: ...here. * testsuite/20_util/duration/comparison_operators/constexpr.cc: New. * testsuite/20_util/time_point/comparison_operators/constexpr.cc: Add. * testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Adjust line numbers. * testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Same. * testsuite/29_atomics/atomic/cons/assign_neg.cc: Same. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. Index: doc/doxygen/user.cfg.in =================================================================== --- doc/doxygen/user.cfg.in (revision 166391) +++ doc/doxygen/user.cfg.in (working copy) @@ -631,6 +631,7 @@ include/system_error \ include/thread \ include/tuple \ + include/typeindex \ include/type_traits \ include/unordered_map \ include/unordered_set \ Index: testsuite/29_atomics/atomic_integral/cons/assign_neg.cc =================================================================== --- testsuite/29_atomics/atomic_integral/cons/assign_neg.cc (revision 166391) +++ testsuite/29_atomics/atomic_integral/cons/assign_neg.cc (working copy) @@ -29,5 +29,5 @@ return 0; } -// { dg-error "deleted" "" { target *-*-* } 544 } +// { dg-error "deleted" "" { target *-*-* } 571 } // { dg-prune-output "include" } Index: testsuite/29_atomics/atomic_integral/cons/copy_neg.cc =================================================================== --- testsuite/29_atomics/atomic_integral/cons/copy_neg.cc (revision 166391) +++ testsuite/29_atomics/atomic_integral/cons/copy_neg.cc (working copy) @@ -29,5 +29,5 @@ return 0; } -// { dg-error "deleted" "" { target *-*-* } 583 } +// { dg-error "deleted" "" { target *-*-* } 610 } // { dg-prune-output "include" } Index: testsuite/29_atomics/atomic/cons/assign_neg.cc =================================================================== --- testsuite/29_atomics/atomic/cons/assign_neg.cc (revision 166391) +++ testsuite/29_atomics/atomic/cons/assign_neg.cc (working copy) @@ -28,5 +28,5 @@ return 0; } -// { dg-error "deleted" "" { target *-*-* } 544 } +// { dg-error "deleted" "" { target *-*-* } 571 } // { dg-prune-output "include" } Index: testsuite/29_atomics/atomic/cons/copy_neg.cc =================================================================== --- testsuite/29_atomics/atomic/cons/copy_neg.cc (revision 166391) +++ testsuite/29_atomics/atomic/cons/copy_neg.cc (working copy) @@ -28,5 +28,5 @@ return 0; } -// { dg-error "deleted" "" { target *-*-* } 583 } +// { dg-error "deleted" "" { target *-*-* } 610 } // { dg-prune-output "include" } Index: testsuite/util/testsuite_common_types.h =================================================================== --- testsuite/util/testsuite_common_types.h (revision 166391) +++ testsuite/util/testsuite_common_types.h (working copy) @@ -462,8 +462,35 @@ } }; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + + struct constexpr_comparison_eq_ne + { + template + void + operator()() + { + static_assert(_Tp1() == _Tp2(), "eq"); + static_assert(!(_Tp1() != _Tp2()), "ne"); + } + }; + + struct constexpr_comparison_operators + { + template + void + operator()() + { + static_assert(!(_Tp() < _Tp()), "less"); + static_assert(_Tp() <= _Tp(), "leq"); + static_assert(!(_Tp() > _Tp()), "more"); + static_assert(_Tp() >= _Tp(), "meq"); + static_assert(_Tp() == _Tp(), "eq"); + static_assert(!(_Tp() != _Tp()), "ne"); + } + }; + // Generator to test standard layout -#ifdef __GXX_EXPERIMENTAL_CXX0X__ struct has_trivial_cons_dtor { template Index: testsuite/20_util/duration/comparison_operators/constexpr.cc =================================================================== --- testsuite/20_util/duration/comparison_operators/constexpr.cc (revision 0) +++ testsuite/20_util/duration/comparison_operators/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_comparison_operators test; + test.operator()(); + return 0; +} Index: testsuite/20_util/duration/comparisons/1.cc =================================================================== --- testsuite/20_util/duration/comparisons/1.cc (revision 166391) +++ testsuite/20_util/duration/comparisons/1.cc (working copy) @@ -1,55 +0,0 @@ -// { dg-options "-std=gnu++0x" } -// { dg-require-cstdint "" } - -// Copyright (C) 2008, 2009 Free Software Foundation -// -// 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 -// . - -// 20.8.3 Class template duration [time.duration] - -#include -#include - -// 20.8.3.6 duration comparisons [time.duration.comparisons] -void -test01() -{ - bool test __attribute__((unused)) = true; - using namespace std::chrono; - - duration d0(12); - duration d1(3); - duration d2(3); - - VERIFY(d1 < d0); - VERIFY(d0 > d1); - - VERIFY(d0 != d1); - VERIFY(d1 == d2); - - VERIFY(d1 <= d2); - VERIFY(d1 >= d2); - - VERIFY(d1 <= d0); - VERIFY(d0 >= d1); -} - -int -main() -{ - test01(); - return 0; -} Index: testsuite/20_util/time_point/comparison_operators/constexpr.cc =================================================================== --- testsuite/20_util/time_point/comparison_operators/constexpr.cc (revision 0) +++ testsuite/20_util/time_point/comparison_operators/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() +{ + using namespace std::chrono; + __gnu_test::constexpr_comparison_operators test; + test.operator()>(); + return 0; +}