From patchwork Mon Apr 14 20:12:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Blaikie X-Patchwork-Id: 550 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 2F8AC36007E for ; Mon, 14 Apr 2014 13:12:37 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id CF95D4ABBA5B; Mon, 14 Apr 2014 13:12:36 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id A0F474ABBA3B for ; Mon, 14 Apr 2014 13:12:36 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :content-type; q=dns; s=default; b=slJr9tIqXdu3RSGi9hu8dlx2iSPlS /IiZlP0N6ORREmFPLnRjDaRawgIaMTK2o7HoRIg0L2X6Fn8mCSIwd2jxupHYuRkn Rd6TZfTuqnCiEK6teDx+KElb9eRM9z0WQ+eivJKggxub4A3ZPa+67aXwOUrYGWlI RXXcOR/KyI1h6o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :content-type; s=default; bh=OjezLbuB5THwpVZBrhgA5vOXBas=; b=FH0 H025SQ1vB3sAfOLOI7zCD71mIDRFIW4wcNBsCuk/cvdnat9vTn8ZjRt6haZaPPxA llcZeUSwE39bFZ3SV22R/g3Q+oTOWS0W+u0DY8wvBwIy9CzczAmV8JxVF60WdffO 5syBEITTzvEobrVGSZu0MG4zck4hsivKgElJfPMg= Received: (qmail 8006 invoked by alias); 14 Apr 2014 20:12:34 -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 7993 invoked by uid 89); 14 Apr 2014 20:12:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f175.google.com Received: from mail-qc0-f175.google.com (HELO mail-qc0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 14 Apr 2014 20:12:31 +0000 Received: by mail-qc0-f175.google.com with SMTP id e16so9313271qcx.20 for ; Mon, 14 Apr 2014 13:12:29 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.91.7 with SMTP id y7mr28326473qgd.3.1397506349308; Mon, 14 Apr 2014 13:12:29 -0700 (PDT) Received: by 10.140.30.74 with HTTP; Mon, 14 Apr 2014 13:12:29 -0700 (PDT) Date: Mon, 14 Apr 2014 13:12:29 -0700 Message-ID: Subject: [patch] [gdb/testsuite] Move start-of-function brace to handle Clang/GCC difference From: David Blaikie To: gdb-patches X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in gdb.cp/cpexprs.exp is verifying behavior that's likely a GCC bug (GCC PR60815 and some in person and IRC conversations with GCC developers). GCC inconsistently places the prologue on either the line with the function name or the line with the function's open brace. Clang consistently uses the function's open brace. Either these tests can be fixed by moving the line to break on and XFAILing them all under GCC, or just making the test neutral to the bug by moving the brace. I generally think it's best to just make the test bug-neutral. I've also had to update the .exp file to tolerate differences in the type of vtable pointers (GCC's "const void ** const" versus Clang's "void **") which required some refactoring. commit c532bc93335823e6ddbaa58abe6f5f58a1dda62e Author: David Blaikie Date: Sun Apr 13 17:37:56 2014 -0700 Adjust start-of-function braces to be compatible with Clang gdb/testsuite/ * gdb.cp/cpexprs.cc: Move braces to the same line as the start of the function to work across GCC and Clang. * gdb.cp/cpexprs.exp: Account for GCC/Clang difference in vtable pointer types (const void ** const V void **). diff --git gdb/testsuite/ChangeLog gdb/testsuite/ChangeLog index e8aefbc..5bcac13 100644 --- gdb/testsuite/ChangeLog +++ gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-04-14 David Blaikie + + * gdb.cp/cpexprs.cc: Move braces to the same line as the start + of the function to work across GCC and Clang. + * gdb.cp/cpexprs.exp: Account for GCC/Clang difference in vtable + pointer types (const void ** const V void **). + 2014-04-14 Tom Tromey * gdb.cp/classes.exp (test_enums): Handle underlying type. diff --git gdb/testsuite/gdb.cp/cpexprs.cc gdb/testsuite/gdb.cp/cpexprs.cc index ee89451..270811b 100644 --- gdb/testsuite/gdb.cp/cpexprs.cc +++ gdb/testsuite/gdb.cp/cpexprs.cc @@ -49,8 +49,7 @@ void tclass::do_something () { } // tclass::do_something // A simple template with multiple template parameters template -void flubber (void) // flubber -{ +void flubber (void) { // flubber A a; B b; C c; @@ -144,128 +143,128 @@ public: int overload (base& b) const { return 5; } // base::overload(base&) const // Operators - int operator+ (base const& o) const // base::operator+ - { return foo_ + o.foo_; } + int operator+ (base const& o) const { // base::operator+ + return foo_ + o.foo_; } - base operator++ (void) // base::operator++ - { ++foo_; return *this; } + base operator++ (void) { // base::operator++ + ++foo_; return *this; } - base operator+=(base const& o) // base::operator+= - { foo_ += o.foo_; return *this; } + base operator+=(base const& o) { // base::operator+= + foo_ += o.foo_; return *this; } - int operator- (base const& o) const // base::operator- - { return foo_ - o.foo_; } + int operator- (base const& o) const { // base::operator- + return foo_ - o.foo_; } - base operator-- (void) // base::operator-- - { --foo_; return *this; } + base operator-- (void) { // base::operator-- + --foo_; return *this; } - base operator-= (base const& o) // base::operator-= - { foo_ -= o.foo_; return *this; } + base operator-= (base const& o) { // base::operator-= + foo_ -= o.foo_; return *this; } - int operator* (base const& o) const // base::operator* - { return foo_ * o.foo_; } + int operator* (base const& o) const { // base::operator* + return foo_ * o.foo_; } - base operator*= (base const& o) // base::operator*= - { foo_ *= o.foo_; return *this; } + base operator*= (base const& o) { // base::operator*= + foo_ *= o.foo_; return *this; } - int operator/ (base const& o) const // base::operator/ - { return foo_ / o.foo_; } + int operator/ (base const& o) const { // base::operator/ + return foo_ / o.foo_; } - base operator/= (base const& o) // base::operator/= - { foo_ /= o.foo_; return *this; } + base operator/= (base const& o) { // base::operator/= + foo_ /= o.foo_; return *this; } - int operator% (base const& o) const // base::operator% - { return foo_ % o.foo_; } + int operator% (base const& o) const { // base::operator% + return foo_ % o.foo_; } - base operator%= (base const& o) // base::operator%= - { foo_ %= o.foo_; return *this; } + base operator%= (base const& o) { // base::operator%= + foo_ %= o.foo_; return *this; } - bool operator< (base const& o) const // base::operator< - { return foo_ < o.foo_; } + bool operator< (base const& o) const { // base::operator< + return foo_ < o.foo_; } - bool operator<= (base const& o) const // base::operator<= - { return foo_ <= o.foo_; } + bool operator<= (base const& o) const { // base::operator<= + return foo_ <= o.foo_; } - bool operator> (base const& o) const // base::operator> - { return foo_ > o.foo_; } + bool operator> (base const& o) const { // base::operator> + return foo_ > o.foo_; } - bool operator>= (base const& o) const // base::operator>= - { return foo_ >= o.foo_; } + bool operator>= (base const& o) const { // base::operator>= + return foo_ >= o.foo_; } - bool operator!= (base const& o) const // base::operator!= - { return foo_ != o.foo_; } + bool operator!= (base const& o) const { // base::operator!= + return foo_ != o.foo_; } - bool operator== (base const& o) const // base::operator== - { return foo_ == o.foo_; } + bool operator== (base const& o) const { // base::operator== + return foo_ == o.foo_; } - bool operator! (void) const // base::operator! - { return !foo_; } + bool operator! (void) const { // base::operator! + return !foo_; } - bool operator&& (base const& o) const // base::operator&& - { return foo_ && o.foo_; } + bool operator&& (base const& o) const { // base::operator&& + return foo_ && o.foo_; } - bool operator|| (base const& o) const // base::operator|| - { return foo_ || o.foo_; } + bool operator|| (base const& o) const { // base::operator|| + return foo_ || o.foo_; } - int operator<< (int value) const // base::operator<< - { return foo_ << value; } + int operator<< (int value) const { // base::operator<< + return foo_ << value; } - base operator<<= (int value) // base::operator<<= - { foo_ <<= value; return *this; } + base operator<<= (int value) { // base::operator<<= + foo_ <<= value; return *this; } - int operator>> (int value) const // base::operator>> - { return foo_ >> value; } + int operator>> (int value) const { // base::operator>> + return foo_ >> value; } - base operator>>= (int value) // base::operator>>= - { foo_ >>= value; return *this; } + base operator>>= (int value) { // base::operator>>= + foo_ >>= value; return *this; } - int operator~ (void) const // base::operator~ - { return ~foo_; } + int operator~ (void) const { // base::operator~ + return ~foo_; } - int operator& (base const& o) const // base::operator& - { return foo_ & o.foo_; } + int operator& (base const& o) const { // base::operator& + return foo_ & o.foo_; } - base operator&= (base const& o) // base::operator&= - { foo_ &= o.foo_; return *this; } + base operator&= (base const& o) { // base::operator&= + foo_ &= o.foo_; return *this; } - int operator| (base const& o) const // base::operator| - { return foo_ | o.foo_; } + int operator| (base const& o) const { // base::operator| + return foo_ | o.foo_; } - base operator|= (base const& o) // base::operator|= - { foo_ |= o.foo_; return *this; } + base operator|= (base const& o) { // base::operator|= + foo_ |= o.foo_; return *this; } - int operator^ (base const& o) const // base::operator^ - { return foo_ ^ o.foo_; } + int operator^ (base const& o) const { // base::operator^ + return foo_ ^ o.foo_; } - base operator^= (base const& o) // base::operator^= - { foo_ ^= o.foo_; return *this; } + base operator^= (base const& o) { // base::operator^= + foo_ ^= o.foo_; return *this; } - base operator= (base const& o) // base::operator= - { foo_ = o.foo_; return *this; } + base operator= (base const& o) { // base::operator= + foo_ = o.foo_; return *this; } - void operator() (void) const // base::operator() - { return; } + void operator() (void) const { // base::operator() + return; } - int operator[] (int idx) const // base::operator[] - { return idx; } + int operator[] (int idx) const { // base::operator[] + return idx; } - void* operator new (size_t size) throw () // base::operator new - { return malloc (size); } + void* operator new (size_t size) throw () { // base::operator new + return malloc (size); } - void operator delete (void* ptr) // base::operator delete - { free (ptr); } + void operator delete (void* ptr) { // base::operator delete + free (ptr); } - void* operator new[] (size_t size) throw () // base::operator new[] - { return malloc (size); } + void* operator new[] (size_t size) throw () { // base::operator new[] + return malloc (size); } - void operator delete[] (void* ptr) // base::operator delete[] - { free (ptr); } + void operator delete[] (void* ptr) { // base::operator delete[] + free (ptr); } - base const* operator-> (void) const // base::opeartor-> - { return this; } + base const* operator-> (void) const { // base::opeartor-> + return this; } - int operator->* (base const& b) const // base::operator->* - { return foo_ * b.foo_; } + int operator->* (base const& b) const { // base::operator->* + return foo_ * b.foo_; } operator char* () const { return const_cast ("hello"); } // base::operator char* operator int () const { return 21; } // base::operator int @@ -298,8 +297,7 @@ class derived : public base1, public base2 { public: derived(void) : foo_ (4) { } // derived::derived - void a_function (void) const // derived::a_function - { + void a_function (void) const { // derived::a_function this->base1::a_function (); this->base2::a_function (); } diff --git gdb/testsuite/gdb.cp/cpexprs.exp gdb/testsuite/gdb.cp/cpexprs.exp index e998d10..beceff5 100644 --- gdb/testsuite/gdb.cp/cpexprs.exp +++ gdb/testsuite/gdb.cp/cpexprs.exp @@ -54,7 +54,7 @@ proc test_breakpoint {func} { # Usage: # add NAME TYPE PRINT LST # add NAME TYPE PRINT - -proc add {func type print lst} { +proc add_type_regexp {func type print lst} { global all_functions CONVAR ADDR set all_functions($func,type) $type @@ -67,13 +67,17 @@ proc add {func type print lst} { regsub {\(void\)} $print {()} print set all_functions($func,print) \ - "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>" + "$CONVAR = {$type} $ADDR <[string_to_regexp $print].*>" if {$lst == "-"} { set lst "$func" } set all_functions($func,list) ".*// [string_to_regexp $lst]" } +proc add {func type print lst} { + add_type_regexp $func [string_to_regexp $type] $print $lst +} + proc get {func cmd} { global all_functions return $all_functions($func,$cmd) @@ -139,32 +143,40 @@ add {base2::a_function} \ # On targets using the ARM EABI, the constructor is expected to return # "this". -proc ctor { type arglist } { +proc ctor_ret { type } { if { [istarget arm*-*eabi*] } { - set ret "$type *" + return "$type *" } else { - set ret "void " + return "void " } +} + +proc ctor_prefix { type } { + set ret [ctor_ret $type] + return "${ret}($type * const" +} + +proc ctor { type arglist } { if { $arglist != "" } { set arglist ", $arglist" } - return "${ret}($type * const$arglist)" + return "[ctor_prefix $type]$arglist)" } add {derived::derived} \ [ctor derived ""] \ - \ - -add {base1::base1(void)} \ - [ctor base1 "const void ** const"] \ +add_type_regexp {base1::base1(void)} \ + "[string_to_regexp [ctor_prefix base1]], (const )?void \\*\\*( const)?\\)" \ - \ - add {base1::base1(int)} \ [ctor base1 "int"] \ - \ - -add {base2::base2} \ - [ctor base2 "const void ** const"] \ +add_type_regexp {base2::base2} \ + "[string_to_regexp [ctor_prefix base2]], (const )?void \\*\\*( const)?\\)" \ - \ - add {base::base(void)} \