Hi Thomas,

Thank you for the catch on dg-regexp! I wasn't aware that it completely ignored 
target selectors.

I'm working on an alternative fix for the test but I'm not sure this isn't a 
libcpp issues.

On 2026-10-29 11:06 a.m., Thomas Schwinge wrote:
> Hi Dave!
> 
> On 2026-10-26T20:28:09-0400, John David Anglin <[email protected]> wrote:
>> testsuite: Fix g++.dg/gomp/deprecate-1.C on hppa targets (v2)
> 
> That's confusing (... to me), in several aspects.  ;-)
> 
>> The g++.dg/gomp/deprecate-1.C test fails on hppa targets (such as
>> hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu) because the leading '#'
>> character is stripped from the diagnostic source line mirror snippet
>> during metadirective warning expansions.

I believe the statement is accurate,  This is the actual diagnostic output on 
linux:

/home/dave/gnu/gcc/gcc/gcc/testsuite/g++.dg/gomp/deprecate-1.C:117:71: warning: 
'default' clause on metadirectives deprecated since OpenMP 5.2,
use 'otherwise' [-Wdeprecated-openmp]
 pragma omp metadirective when (device={arch("blahblah")}: nothing) default 
(nothing)         /* { dg-warning "'default' clause on
metadirectives deprecated since OpenMP 5.2, use 'otherwise'" } */
                                                                    ^~~~~~~
                                                                    otherwise


> I have difficulties (a) parsing that last sentence, and (b) understanding
> why/how '#' appearing as part of diagnostics would be handled differently
> for HPPA vs. other targets?

There is some endian dependence in libcpp/lex.cc but the test doesn't fail on 
powerpc64be.
At this time, I don't know why hppa is different.  It's only different on line 
117 which
has a parenthetical nested expression.

> Why is this (apparently) a problem only in 'g++.dg/gomp/deprecate-1.C',
> but not 'gcc.dg/gomp/deprecate-1.c', which uses a lot of the same
> patterns?

>From my research, the C front end handles macro line tracking using a simpler 
>source location
cache.  The C++ front end uses tokenized fix-hits.  But I have no knowledge of 
the details.
>> This patch fixes the failure by restricting the rigid literal multiline
> 
> This test case 'g++.dg/gomp/deprecate-1.C' was added in 
> commit d5320610cd3614a83ea1f2c8122a6cfbad987eab
> "openmp: Provide fixit hints for -Wdeprecated-openmp diagnostics from C++ FE",
> and I presume Jakub's intent was to test the exact multiline output
> formatting -- which we've now (partly) lost?
> 
>> block to non-hppa targets, and appending target-specific dg-regexp
>> directives to the end of the file to gracefully consume the unhashed
>> caret fragments on PA-RISC architectures without altering file line
>> indices.
> 
> As far as I can tell, there doesn't exist a concept of "target-specific
> dg-regexp directives": 'dg-regexp' effectively only considers its first
> argument, and silently drops everything else.
> 
> (Of course, that's not the most friendly API, and also it's not
> documented in 'gcc/doc/sourcebuild.texi' at all.  ..., and I've just
> realized that I already had filed <https://gcc.gnu.org/PR119511>
> "Harden 'dg-regexp', fix misuses"...)  ;-)
> 
>> gcc/testsuite/ChangeLog:
>>
>>      * g++.dg/gomp/deprecate-1.C: Restrict the final literal multiline
>>      verification block to non-hppa targets, and append trailing
>>      dg-regexp directives to consume the unhashed diagnostic caret
>>      fragments on hppa targets.
> 
>> --- a/gcc/testsuite/g++.dg/gomp/deprecate-1.C
>> +++ b/gcc/testsuite/g++.dg/gomp/deprecate-1.C
>> @@ -109,16 +109,14 @@ bar ()
>>     { dg-end-multiline-output "" } */
>>    ;
>>    #pragma omp master                                /* { dg-warning 
>> "'master' construct deprecated since OpenMP 5.1, use 'masked'" } */
>> -/* { dg-begin-multiline-output "" }
>> +/* { dg-begin-multiline-output "" { target { ! hppa*-*-* } } }
>>     #pragma omp master
>>                                                                              
>>                                                         ^
>>     { dg-end-multiline-output "" } */
>>    ;
>>    #pragma omp metadirective when (device={arch("blahblah")}: nothing) 
>> default (nothing)             /* { dg-warning "'default' clause on 
>> metadirectives deprecated since OpenMP 5.2, use 'otherwise'" } */
>> -/* { dg-begin-multiline-output "" }
>> -   #pragma omp metadirective when (device={arch("blahblah")}: nothing) 
>> default (nothing)
>> -                                                                       
>> ^~~~~~~
>> -                                                                       
>> otherwise
>> -   { dg-end-multiline-output "" } */
> 
> Was it intentional that you've dropped this multiline output check
> entirely, instead of restricting to 'target { ! hppa*-*-* }' (as above)?
> 
>> +/* { dg-regexp ".*pragma omp metadirective when.*" { target hppa*-*-* } } */
>> +/* { dg-regexp ".*\\^~~~~~~.*" { target hppa*-*-* } } */
>> +/* { dg-regexp ".*otherwise.*" { target hppa*-*-* } } */
>>    ;
>>  }
> 
> As per my comment above, while the '{ target hppa*-*-* }' appears to
> conditionalize this DejaGnu directive in the usual way, in reality it
> doesn't, so these 'dg-regexp's are actually effective unconditionally.
> They PASS, at least, but not anymore fully testing what was intended to
> be tested.
> 
> I don't want us to get hung up about this one test case, but...  :-)

Maybe I should revert the change and file a bug report?  I spent a lot of time 
trying
to fix the match and I'm not convinced there's currently a way to do it without 
modifying
the original intent.  This is definitely frustrating!

Regards,
Dave
-- 
John David Anglin  [email protected]

Reply via email to