From patchwork Thu Sep 15 22:06:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 15682 Received: (qmail 68331 invoked by alias); 15 Sep 2016 22:06:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 68317 invoked by uid 89); 15 Sep 2016 22:06:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=20160916, 2016-09-16 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Sep 2016 22:06:42 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75A9225CD5; Thu, 15 Sep 2016 22:06:41 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8FM6btQ012347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 15 Sep 2016 18:06:40 -0400 Date: Fri, 16 Sep 2016 00:06:37 +0200 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org, Tom Tromey Subject: [testsuite patchv2] Fix false FAIL in gdb.cp/casts.exp Message-ID: <20160915220637.GA18826@host1.jankratochvil.net> References: <20160911141027.GA10024@host1.jankratochvil.net> <33a1daf5-4b61-f1d0-4342-d49195a79aa0@redhat.com> <87wpid2t2o.fsf@tromey.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87wpid2t2o.fsf@tromey.com> User-Agent: Mutt/1.7.0 (2016-08-17) X-IsSubscribed: yes On Thu, 15 Sep 2016 15:25:35 +0200, Tom Tromey wrote: > >>>>> "Pedro" == Pedro Alves writes: > > Pedro> So perhaps a better fix is to move that particular test to a > Pedro> separate testcase that force-compiles with -std=c++03. > > Pedro> Adding Tromey, who wrote the test initially. > > Yeah, I think that's correct. According to the patch email, I did this > because there wasn't a way to tell which version of C++ was in use: Is this file OK for check-in? Thanks, Jan gdb/testsuite/ChangeLog 2016-09-16 Jan Kratochvil * gdb.cp/casts.cc (decltype): Move it ... (main): ... with its call to ... * gdb.cp/casts03.cc: ... a new file. * gdb.cp/casts.exp: Add new file casts03.cc, move decltype test to it. diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc index 43f112f..543db89 100644 --- a/gdb/testsuite/gdb.cp/casts.cc +++ b/gdb/testsuite/gdb.cp/casts.cc @@ -34,14 +34,6 @@ struct DoublyDerived : public VirtuallyDerived, { }; -// Confuse a simpler approach. - -double -decltype(int x) -{ - return x + 2.0; -} - int main (int argc, char **argv) { @@ -56,7 +48,5 @@ main (int argc, char **argv) Alpha *ad = &derived; Alpha *add = &doublyderived; - double y = decltype(2); - return 0; /* breakpoint spot: casts.exp: 1 */ } diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp index 34a2492..57a56b8 100644 --- a/gdb/testsuite/gdb.cp/casts.exp +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -27,7 +27,7 @@ if { [skip_cplus_tests] } { continue } -standard_testfile .cc +standard_testfile .cc casts03.cc if [get_compiler_info "c++"] { return -1 @@ -110,10 +110,6 @@ gdb_test "print reinterpret_cast (b)" "Invalid reinterpret_cast" \ gdb_test "print reinterpret_cast (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \ "reinterpret_cast to reference type" -# Test that keyword shadowing works. - -gdb_test "whatis decltype(5)" " = double" - # Basic tests using typeof. foreach opname {__typeof__ __typeof __decltype} { @@ -176,3 +172,23 @@ gdb_test "print dynamic_cast (add)" \ gdb_test "print dynamic_cast (add)" \ " = \\(Gamma \\*\\) $nonzero_hex" \ "dynamic_cast to sibling" + +if {[prepare_for_testing $testfile.exp ${testfile}03 $srcfile2 \ + {debug c++ additional_flags=-std=c++03}]} { + return -1 +} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# Prevent symbol on address 0x0 being printed. +gdb_test_no_output "set print symbol off" + +gdb_breakpoint [gdb_get_line_number "casts.exp: 1" $srcfile2] +gdb_continue_to_breakpoint "end of casts03" + +# Test that keyword shadowing works. + +gdb_test "whatis decltype(5)" " = double" diff --git a/gdb/testsuite/gdb.cp/casts03.cc b/gdb/testsuite/gdb.cp/casts03.cc new file mode 100644 index 0000000..58d9a42 --- /dev/null +++ b/gdb/testsuite/gdb.cp/casts03.cc @@ -0,0 +1,32 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 Free Software Foundation, Inc. + + This program 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 of the License, or + (at your option) any later version. + + This program 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 program. If not, see . */ + +// Confuse a simpler approach. + +double +decltype(int x) +{ + return x + 2.0; +} + +int +main (int argc, char **argv) +{ + double y = decltype(2); + + return 0; /* breakpoint spot: casts.exp: 1 */ +}