]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc-dg.exp (cleanup-ada-spec): New procedure.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 4 Oct 2012 21:34:13 +0000 (21:34 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 4 Oct 2012 21:34:13 +0000 (21:34 +0000)
* 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.

From-SVN: r192106

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/dump-ada-spec-1.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/dump-ada-spec-1.c [new file with mode: 0644]
gcc/testsuite/lib/gcc-dg.exp
gcc/testsuite/lib/scanasm.exp

index 6d99e71c68d3f77a22011222fa4e932cbfd332e4..f7003f989cbe2a482de824f3798fde9a8651afee 100644 (file)
@@ -1,3 +1,12 @@
+2012-10-04  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * 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.
+
 2012-10-04  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/lto/20120723_0.c: Skip on SPARC 32-bit.
diff --git a/gcc/testsuite/g++.dg/other/dump-ada-spec-1.C b/gcc/testsuite/g++.dg/other/dump-ada-spec-1.C
new file mode 100644 (file)
index 0000000..eb249e7
--- /dev/null
@@ -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 } } */
diff --git a/gcc/testsuite/gcc.dg/dump-ada-spec-1.c b/gcc/testsuite/gcc.dg/dump-ada-spec-1.c
new file mode 100644 (file)
index 0000000..eb249e7
--- /dev/null
@@ -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 2cc49f7e6b7705c7460a98afd1a7f8379b8cb504..b3f8d3bb1855c85873e52e1f7075b758affbc571 100644 (file)
@@ -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 c513857cd8d00a9138b083786488cf37d989db9c..598948e81474244527d85c864eff6f4a8f47d80e 100644 (file)
@@ -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 } {