diff mbox series

libgomp testsuite: tell warning from error diagnostics, etc. [PR80219, PR85303]

Message ID 87blgkgdqg.fsf@euler.schwinge.homeip.net
State New
Headers show
Series libgomp testsuite: tell warning from error diagnostics, etc. [PR80219, PR85303] | expand

Commit Message

Thomas Schwinge Oct. 30, 2020, 11:22 a.m. UTC
Hi!

Turns out that GCC PR85303 "[testsuite, libgomp] dg-message not
supported" is the very same problem as (the libgomp aspect of) GCC
PR80219 "relative line numbers only working if gcc_{error,warning}_prefix
defined" (see rationale in there).  OK to push the attached patch for
"libgomp testsuite: tell warning from error diagnostics, etc. [PR80219,
PR85303]"?  This changes makes 'dg-warning', 'dg-error', 'dg-bogus',
'dg-message' behave as expected, and also enables use of relative line
numbers as well as 'dg-line'.  (No testsuite regressions.)


I (later) have a proper use for that, but with that fixed, you can then
do standard things as follows:

    --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c
    +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c
    @@ -56,17 +56,17 @@ int main ()

       /* GR, WS, VS.  */
       {
    -#define GANGS 0 /* { dg-warning "'num_gangs' value must be positive" "" { target c } } */
    -    int gangs_actual = GANGS;
    +#define GANGS 0
    +    int gangs_actual = GANGS; /* { dg-warning "'num_gangs' value must be positive" "" { target c } .-1 } */
         int gangs_min, gangs_max, workers_min, workers_max, vectors_min, vectors_max;
         gangs_min = workers_min = vectors_min = INT_MAX;
         gangs_max = workers_max = vectors_max = INT_MIN;
     #pragma acc parallel copy (gangs_actual) \
       reduction (min: gangs_min, workers_min, vectors_min) reduction (max: gangs_max, workers_max, vectors_max) \
    -  num_gangs (GANGS) /* { dg-warning "'num_gangs' value must be positive" "" { target c++ } } */
    +  num_gangs (GANGS) // { dg-line LiNE }
         {
           /* We're actually executing with num_gangs (1).  */
    -      gangs_actual = 1;
    +      gangs_actual = 1; /* { dg-warning "'num_gangs' value must be positive" "" { target c++ } LiNE } */
           for (int i = 100 * gangs_actual; i > -100 * gangs_actual; --i)
        {
          /* <https://gcc.gnu.org/PR80547>.  */
    @@ -98,13 +98,13 @@ int main ()

       /* GP, WS, VS.  */
       {
    -#define GANGS 0 /* { dg-warning "'num_gangs' value must be positive" "" { target c } } */
    +#define GANGS 0 /* { dg-message "warning: 'num_gangs' value must be positive" "" { target c } } */
         int gangs_actual = GANGS;
         int gangs_min, gangs_max, workers_min, workers_max, vectors_min, vectors_max;
         gangs_min = workers_min = vectors_min = INT_MAX;
         gangs_max = workers_max = vectors_max = INT_MIN;
     #pragma acc parallel copy (gangs_actual) \
    -  num_gangs (GANGS) /* { dg-warning "'num_gangs' value must be positive" "" { target c++ } } */
    +  num_gangs (GANGS) // { dg-line LaNE }
         {
           /* We're actually executing with num_gangs (1).  */
           gangs_actual = 1;
    @@ -115,7 +115,7 @@ int main ()
          workers_min = workers_max = acc_worker ();
          vectors_min = vectors_max = acc_vector ();
        }
    -    }
    +    } /* { dg-message "'num_gangs' value must be positive" "" { target c++ } LaNE } */
         if (gangs_actual != 1)
           __builtin_abort ();
         if (gangs_min != 0 || gangs_max != gangs_actual - 1


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

Comments

Jakub Jelinek Oct. 30, 2020, 11:25 a.m. UTC | #1
On Fri, Oct 30, 2020 at 12:22:31PM +0100, Thomas Schwinge wrote:
> Turns out that GCC PR85303 "[testsuite, libgomp] dg-message not
> supported" is the very same problem as (the libgomp aspect of) GCC
> PR80219 "relative line numbers only working if gcc_{error,warning}_prefix
> defined" (see rationale in there).  OK to push the attached patch for
> "libgomp testsuite: tell warning from error diagnostics, etc. [PR80219,
> PR85303]"?  This changes makes 'dg-warning', 'dg-error', 'dg-bogus',
> 'dg-message' behave as expected, and also enables use of relative line
> numbers as well as 'dg-line'.  (No testsuite regressions.)

Ok, thanks.

> 	libgomp/
> 	PR testsuite/80219
> 	PR testsuite/85303
> 	* testsuite/lib/libgomp.exp (libgomp_init): Set
> 	'gcc_warning_prefix', 'gcc_error_prefix'.
> ---
>  libgomp/testsuite/lib/libgomp.exp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
> index 5d86e2ac095f..72d001186a57 100644
> --- a/libgomp/testsuite/lib/libgomp.exp
> +++ b/libgomp/testsuite/lib/libgomp.exp
> @@ -241,6 +241,12 @@ proc libgomp_init { args } {
>      if { $offload_additional_options != "" } {
>  	lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
>      }
> +
> +    # Tell warning from error diagnostics.  This fits for C, C++, and Fortran.
> +    global gcc_warning_prefix
> +    set gcc_warning_prefix "\[Ww\]arning:"
> +    global gcc_error_prefix
> +    set gcc_error_prefix "(\[Ff\]atal )?\[Ee\]rror:"
>  }
>  
>  #
> -- 
> 2.17.1
> 


	Jakub
Thomas Schwinge Nov. 2, 2020, 1:35 p.m. UTC | #2
Hi!

On 2020-10-30T12:25:38+0100, Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> On Fri, Oct 30, 2020 at 12:22:31PM +0100, Thomas Schwinge wrote:
>> Turns out that GCC PR85303 "[testsuite, libgomp] dg-message not
>> supported" is the very same problem as (the libgomp aspect of) GCC
>> PR80219 "relative line numbers only working if gcc_{error,warning}_prefix
>> defined" (see rationale in there).  OK to push the attached patch for
>> "libgomp testsuite: tell warning from error diagnostics, etc. [PR80219,
>> PR85303]"?  This changes makes 'dg-warning', 'dg-error', 'dg-bogus',
>> 'dg-message' behave as expected, and also enables use of relative line
>> numbers as well as 'dg-line'.  (No testsuite regressions.)
>
> Ok, thanks.

As posted, pushed "libgomp testsuite: tell warning from error
diagnostics, etc. [PR80219, PR85303]" to master branch in commit
528507fa0314c75d1105890e4781a475c8badd7c, and backported to
releases/gcc-10 branch in commit
591e878fc6dd08502429a8e480d8e7d966836ca9, releases/gcc-9 branch in commit
d824c5df1714403067f2a7170dd884887ce04712, releases/gcc-8 branch in commit
3940a3ff2be0b445a5b24a222e83669e570f32a9.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
diff mbox series

Patch

From 47e35a661859ade764fe4ed2a4e3e2205c19dd90 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 29 Oct 2020 10:29:19 +0100
Subject: [PATCH] libgomp testsuite: tell warning from error diagnostics, etc.
 [PR80219, PR85303]

This changes makes 'dg-warning', 'dg-error', 'dg-bogus', 'dg-message' behave as
expected, and also enables use of relative line numbers as well as 'dg-line'.

	libgomp/
	PR testsuite/80219
	PR testsuite/85303
	* testsuite/lib/libgomp.exp (libgomp_init): Set
	'gcc_warning_prefix', 'gcc_error_prefix'.
---
 libgomp/testsuite/lib/libgomp.exp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 5d86e2ac095f..72d001186a57 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -241,6 +241,12 @@  proc libgomp_init { args } {
     if { $offload_additional_options != "" } {
 	lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
     }
+
+    # Tell warning from error diagnostics.  This fits for C, C++, and Fortran.
+    global gcc_warning_prefix
+    set gcc_warning_prefix "\[Ww\]arning:"
+    global gcc_error_prefix
+    set gcc_error_prefix "(\[Ff\]atal )?\[Ee\]rror:"
 }
 
 #
-- 
2.17.1