On Fri, 2016-12-09 at 02:48 +0100, Bernd Schmidt wrote:
> On 12/08/2016 10:47 PM, David Malcolm wrote:
> 
> > Is (A) OK, or would you prefer (B)?   (I prefer (A) fwiw)
> 
> Oh well, just keep it as it is.
> 
> 
> Bernd

Thanks.  Unfortunately, applying the "locate_file" patch
  https://gcc.gnu.org/ml/gcc-patches/2016-11/msg01186.html
would now introduce a regression in a recently-added test case:

Tests changing outcome in gcc/testsuite/gcc/gcc.sum: 2
------------------------------------------------------

 PASS -> FAIL : gcc.dg/pr78213.c (test for excess errors)
 PASS -> FAIL : gcc.dg/pr78213.c -fself-test (test for warnings, line )

This test case was added in r242748 (aka
 7c889936fe48e15a57b6d1509197a1492d49b0fb) by aldy (CCed) to fix
PR target/78213: 

commit 7c889936fe48e15a57b6d1509197a1492d49b0fb
Author: aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Nov 23 12:18:23 2016 +0000

        PR target/78213
        * opts.c (finish_options): Set -fsyntax-only if running self
        tests.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242748 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 192d6e4..ec1fe96 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-11-23  Aldy Hernandez  <al...@redhat.com>
+
+       PR target/78213
+       * opts.c (finish_options): Set -fsyntax-only if running self
+       tests.
+
 2016-11-23  Richard Biener  <rguent...@suse.de>
 
        PR middle-end/71762
diff --git a/gcc/opts.c b/gcc/opts.c
index d2d6100..cb20154 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -744,6 +744,14 @@ finish_options (struct gcc_options *opts, struct 
gcc_options *opts_set,
       opts->x_flag_toplevel_reorder = 0;
     }
 
+  /* -fself-test depends on the state of the compiler prior to
+     compiling anything.  Ideally it should be run on an empty source
+     file.  However, in case we get run with actual source, assume
+     -fsyntax-only which will inhibit any compiler initialization
+     which may confuse the self tests.  */
+  if (opts->x_flag_self_test)
+    opts->x_flag_syntax_only = 1;
+
   if (opts->x_flag_tm && opts->x_flag_non_call_exceptions)
     sorry ("transactional memory is not supported with non-call exceptions");
 
diff --git a/gcc/testsuite/gcc.dg/pr78213.c b/gcc/testsuite/gcc.dg/pr78213.c
new file mode 100644
index 0000000..e43c83c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr78213.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fself-test" } */
+
+/* Verify that -fself-test does not fail on a non empty source.  */
+
+int i;                                                                         
 void bar();                                       
+{
+  while (i--)
+    bar();
+}
+/* { dg-message "fself\-test: " "-fself-test" { target *-*-* } 0 } */

The problem is that this DejaGnu test case uses -fself-test, and
doesn't provide any arguments.  With the locate_file patch, we need to
pass the path to $(srcdir)/testsuite/selftests as an argument to -fself
-test, and it's not clear to me how to do that sanely in a DejaGnu test
case; if I pass in a dummy value (like for pr71591.c), then the
selftests that use locate_file fail.

(fwiw I'm not particularly fond of us running the selftests a second
time from within DejaGnu, or for that matter, of supporting non-empty
source files in the selftests; my preferred fix for this is to delete
gcc/testsuite/gcc.dg/pr78213.c).

The motivation for the patch is to be able to verify that the RTL
function parser code works properly, by having selftests that read RTL
function dumps, and asserting various properties of the in-memory
representation.  Doing this means we need some way to locate the
dumpfiles from within the selftests, hence selftest::locate_file.

Thoughts?
Dave

Reply via email to