From patchwork Fri Jul 16 17:05:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 59119 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 96104B6F11 for ; Sat, 17 Jul 2010 03:04:15 +1000 (EST) Received: (qmail 7790 invoked by alias); 16 Jul 2010 17:04:12 -0000 Received: (qmail 7641 invoked by uid 22791); 16 Jul 2010 17:04:10 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CP, 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; Fri, 16 Jul 2010 17:04:04 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6GH42H7027958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 16 Jul 2010 13:04:03 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6GH424p007713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Jul 2010 13:04:02 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o6GH5pJa007179; Fri, 16 Jul 2010 19:05:51 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6GH5piQ007177; Fri, 16 Jul 2010 19:05:51 +0200 Date: Fri, 16 Jul 2010 19:05:51 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Jeffrey Yasskin Subject: [testsuite] Allow g++.dg/guality/ and c-c++-common/guality/ tests Message-ID: <20100716170551.GY20208@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! This patch allows C++ guality tests as well as C tests compiled by both C and C++ compilers. Ok for trunk? BTW, the redeclaration1.C test, which I've randomly picked from g++.dg/debug/dwarf2/ and turned into a runtime testcase, has the second test UNSUPPORTED, not sure if it is a gdb bug or g++ bug (and FAILs with -flto/-fwhopr, but -flto/-fwhopr and debug info don't go well together at all). 2010-07-16 Jakub Jelinek * gcc.dg/guality/guality.exp: Run also c-c++-common/guality/ tests. * gcc.dg/guality/guality.h: Include unistd.h. Make the header usable in C++. (gualcvt): New overloaded inline. (GUALCVT): Use it for C++. * g++.dg/guality/guality.exp: New. * g++.dg/guality/guality.h: New. * g++.dg/guality/redeclaration1.C: New test. * g++.dg/dg.exp: Prune also guality/* tests. * gcc.dg/guality/pr43141.c: Moved to... * c-c++-common/guality/pr43141.c: ... here. Jakub --- gcc/testsuite/gcc.dg/guality/guality.exp.jj 2009-10-07 09:22:39.000000000 +0200 +++ gcc/testsuite/gcc.dg/guality/guality.exp 2010-07-16 18:19:58.000000000 +0200 @@ -43,6 +43,7 @@ if {[check_guality " } "]} { gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" + gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "-Wc++-compat" } if [info exists guality_gdb_name] { --- gcc/testsuite/gcc.dg/guality/guality.h.jj 2010-02-12 13:25:22.000000000 +0100 +++ gcc/testsuite/gcc.dg/guality/guality.h 2010-07-16 18:40:48.000000000 +0200 @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. #include #include #include +#include /* This is a first cut at checking that debug information matches run-time. The idea is to annotate programs with GUALCHK* macros @@ -61,6 +62,7 @@ typedef intmax_t gualchk_t; /* Convert a pointer or integral type to the widest integral type, as expected by guality_check. */ +#ifndef __cplusplus #define GUALCVT(val) \ ((gualchk_t)__builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (val), gualchk_t), \ @@ -69,6 +71,30 @@ typedef intmax_t gualchk_t; (__builtin_classify_type (val) \ == __builtin_classify_type (&guality_skip), \ (uintptr_t)(val),(intptr_t)(val)))) +#else +template +inline __attribute__((always_inline)) gualchk_t +gualcvt (T *val) +{ + return (uintptr_t) val; +} + +template +inline __attribute__((always_inline)) gualchk_t +gualcvt (T val) +{ + return (intptr_t) val; +} + +template <> +inline __attribute__((always_inline)) gualchk_t +gualcvt (gualchk_t val) +{ + return val; +} + +#define GUALCVT(val) gualcvt (val) +#endif /* Attach a debugger to the current process and verify that the string EXPR, evaluated by the debugger, yields the gualchk_t number VAL. @@ -195,7 +221,7 @@ main (int argc, char *argv[]) else { int len = strlen (guality_gdb_command) + sizeof (GUALITY_GDB_ARGS); - char *buf = __builtin_alloca (len); + char *buf = (char *) __builtin_alloca (len); strcpy (buf, guality_gdb_command); strcat (buf, GUALITY_GDB_ARGS); guality_gdb_command = buf; --- gcc/testsuite/g++.dg/guality/guality.exp.jj 2010-07-16 18:03:23.000000000 +0200 +++ gcc/testsuite/g++.dg/guality/guality.exp 2010-07-16 18:49:29.000000000 +0200 @@ -0,0 +1,53 @@ +# This harness is for tests that should be run at all optimisation levels. + +load_lib g++-dg.exp +load_lib gcc-gdb-test.exp + +# Disable on darwin until radr://7264615 is resolved. +if { [istarget *-*-darwin*] } { + return +} + +proc check_guality {args} { + set result [eval check_compile guality_check executable $args "-g -O0"] + set lines [lindex $result 0] + set output [lindex $result 1] + set ret 0 + if {[string match "" $lines]} { + set execout [g++_load "./$output"] + set ret [string match "*1 PASS, 0 FAIL, 0 UNRESOLVED*" $execout] + } + remote_file build delete $output + return $ret +} + +dg-init + +global GDB +if ![info exists ::env(GUALITY_GDB_NAME)] { + if [info exists GDB] { + set guality_gdb_name "$GDB" + } else { + set guality_gdb_name "[transform gdb]" + } + setenv GUALITY_GDB_NAME "$guality_gdb_name" +} + +if {[check_guality " + #include \"$srcdir/$subdir/guality.h\" + volatile long int varl = 6; + int main (int argc, char *argv\[\]) + { + GUALCHKVAL (varl); + return 0; + } +"]} { + gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" + gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "" +} + +if [info exists guality_gdb_name] { + unsetenv GUALITY_GDB_NAME +} + +dg-finish --- gcc/testsuite/g++.dg/guality/guality.h.jj 2010-07-16 18:03:21.000000000 +0200 +++ gcc/testsuite/g++.dg/guality/guality.h 2010-07-16 18:03:17.000000000 +0200 @@ -0,0 +1 @@ +#include "../../gcc.dg/guality/guality.h" --- gcc/testsuite/g++.dg/guality/redeclaration1.C.jj 2010-07-16 18:12:29.000000000 +0200 +++ gcc/testsuite/g++.dg/guality/redeclaration1.C 2010-07-16 18:44:34.000000000 +0200 @@ -0,0 +1,26 @@ +// { dg-do run } +// { dg-options "-g" } + +volatile int l; + +namespace S +{ + int i = 24; + void __attribute__((noinline)) + f() + { + int i = 42; + l = i; // { dg-final { gdb-test 13 "i" "42" } } + { + extern int i; + l = i; // { dg-final { gdb-test 16 "i" "24" } } + } + } +} + +int +main (void) +{ + S::f (); + return 0; +} --- gcc/testsuite/g++.dg/dg.exp.jj 2010-04-16 19:35:47.000000000 +0200 +++ gcc/testsuite/g++.dg/dg.exp 2010-07-16 18:07:00.000000000 +0200 @@ -1,4 +1,4 @@ -# Copyright (C) 2000, 2007 Free Software Foundation, Inc. +# Copyright (C) 2000, 2007, 2009, 2010 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 @@ -47,6 +47,7 @@ set tests [prune $tests $srcdir/$subdir/ set tests [prune $tests $srcdir/$subdir/tree-prof/*] set tests [prune $tests $srcdir/$subdir/torture/*] set tests [prune $tests $srcdir/$subdir/graphite/*] +set tests [prune $tests $srcdir/$subdir/guality/*] # Main loop. dg-runtest $tests "" $DEFAULT_CXXFLAGS --- gcc/testsuite/gcc.dg/guality/pr43141.c.jj 2010-04-05 18:48:36.000000000 +0200 +++ gcc/testsuite/gcc.dg/guality/pr43141.c 2010-07-16 18:54:44.000000000 +0200 @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-g" } */ - -int i; -static int f(int) __attribute ((noinline)); -static int f(int x) -{ - return i; -} - -int main() -{ - return f(42); -} - -/* { dg-final { gdb-test 8 "sizeof (x)" "sizeof (int)" } } */ --- gcc/testsuite/c-c++-common/guality/pr43141.c.jj 2010-07-16 18:08:57.000000000 +0200 +++ gcc/testsuite/c-c++-common/guality/pr43141.c 2010-04-05 18:48:36.000000000 +0200 @@ -0,0 +1,16 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int i; +static int f(int) __attribute ((noinline)); +static int f(int x) +{ + return i; +} + +int main() +{ + return f(42); +} + +/* { dg-final { gdb-test 8 "sizeof (x)" "sizeof (int)" } } */