From patchwork Thu Oct 4 11:10:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 189088 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 11B902C0362 for ; Thu, 4 Oct 2012 21:13:04 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349953985; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=hpuQiiVGQpGYL9AZQBtlbaqnHfo=; b=RovTlFtXsvcAIVJ 3L2pd8fVB7Vgj/xD/PSvbqlvqomOphzOEMyCTPVAoUgAR4x+9TR02sRigW5Y2sRS eX9Fn7N4kUGhIscQgMt9nvJkd//0bqvOe4nvHQ6n+dcWUXMdHSZSBr98fGRfGMB2 L+6GUU/oHTNqu/FVBhyIbknVg1oc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=TMbo/qNAfHB+MtEUDNq7Q2jLaE8h6tg5vhlGY067NNv7mgEfUi9to1JSci/qT9 6bTAtH/o1E5xe6wHEtqfi1WB42tUSmCQ277Aq4cepUKbqU7YuRWDPNhvibWmv1k5 m7wlItI3N6PyQ10An1ejPKGLBdAzf24t1GUwOaCpikEhs=; Received: (qmail 9071 invoked by alias); 4 Oct 2012 11:12:58 -0000 Received: (qmail 9061 invoked by uid 22791); 4 Oct 2012 11:12:55 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Oct 2012 11:12:49 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E85A8290073 for ; Thu, 4 Oct 2012 13:12:58 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rYtLeosF6Z8p for ; Thu, 4 Oct 2012 13:12:58 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 9D507290028 for ; Thu, 4 Oct 2012 13:12:58 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [testsuite] Add support for -fdump-ada-spec Date: Thu, 04 Oct 2012 13:10:20 +0200 Message-ID: <2133991.HJNE3teHMl@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) 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 Hi, the recent breakage of -fdump-ada-spec revealed that the switch isn't exercised in the testsuite. This patch adds the missing support. Tested on x86_64-suse-linux, OK for mainline? What of the 4.7 branch? 2012-10-04 Eric Botcazou * lib/gcc-dg.exp (cleanup-ada-spec): New procedure. * lib/scanasm.exp (get_ada_spec_filename): Likewise. (scan-ada-spec): Likewise. (scan-ada-spec-not): Likewise. * gcc.dg/dump-ada-spec-1.c: New test. * g++.dg/other/dump-ada-spec-1.C: Likewise. Index: lib/gcc-dg.exp =================================================================== --- lib/gcc-dg.exp (revision 192073) +++ lib/gcc-dg.exp (working copy) @@ -503,6 +503,19 @@ proc cleanup-stack-usage { } { } } +# Remove an Ada spec file for the current test. +proc cleanup-ada-spec { } { + set testcase [testname-for-summary] + remove-build-file "[get_ada_spec_filename $testcase]" + + # Clean up files for additional source files. + if [info exists additional_sources] { + foreach srcfile $additional_sources { + remove-build-file "[get_ada_spec_filename $srcfile]" + } + } +} + # Remove all dump files with the provided suffix. proc cleanup-dump { suffix } { set testcase [testname-for-summary] Index: lib/scanasm.exp =================================================================== --- lib/scanasm.exp (revision 192073) +++ lib/scanasm.exp (working copy) @@ -184,6 +184,38 @@ proc scan-stack-usage-not { args } { dg-scan "scan-file-not" 0 $testcase $output_file $args } +# Return the filename of the Ada spec corresponding to the argument. + +proc get_ada_spec_filename { testcase } { + # The name might include a list of options; extract the file name. + set filename [lindex $testcase 0] + set tailname [file tail $filename] + set extension [string trimleft [file extension $tailname] {.}] + set rootname [regsub -all {\-} [file rootname $tailname] {_}] + + return [string tolower "${rootname}_${extension}.ads"] +} + +# Look for a pattern in the .ads file produced by the compiler. See +# dg-scan for details. + +proc scan-ada-spec { args } { + set testcase [testname-for-summary] + set output_file "[get_ada_spec_filename $testcase]" + + dg-scan "scan-file" 1 $testcase $output_file $args +} + +# Check that a pattern is not present in the .ads file produced by the +# compiler. See dg-scan for details. + +proc scan-ada-spec-not { args } { + set testcase [testname-for-summary] + set output_file "[get_ada_spec_filename $testcase]" + + dg-scan "scan-file-not" 0 $testcase $output_file $args +} + # Call pass if pattern is present given number of times, otherwise fail. proc scan-assembler-times { args } { if { [llength $args] < 2 } { Index: gcc.dg/dump-ada-spec-1.c =================================================================== --- gcc.dg/dump-ada-spec-1.c (revision 0) +++ gcc.dg/dump-ada-spec-1.c (revision 0) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-ada-spec" } */ + +struct S +{ + int i; +}; + +/* { dg-final { scan-ada-spec "type S is record" } } */ +/* { dg-final { cleanup-ada-spec } } */ Index: g++.dg/other/dump-ada-spec-1.C =================================================================== --- g++.dg/other/dump-ada-spec-1.C (revision 0) +++ g++.dg/other/dump-ada-spec-1.C (revision 0) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-ada-spec" } */ + +struct S +{ + int i; +}; + +/* { dg-final { scan-ada-spec "type S is record" } } */ +/* { dg-final { cleanup-ada-spec } } */