[PATCH] C testsuite, silence a FreeBSD libc warning

Andreas Tobler andreast-list@fgznet.ch
Mon Sep 30 18:31:00 GMT 2019


On 30.09.19 19:47, Jakub Jelinek wrote:
> On Mon, Sep 30, 2019 at 07:41:00PM +0200, Andreas Tobler wrote:
>> --- fprintf-2.c	(revision 276292)
>> +++ fprintf-2.c	(working copy)
>> @@ -1,7 +1,8 @@
>>   /* Verify that calls to fprintf don't get eliminated even if their
>>      result on success can be computed at compile time (they can fail).
>>      The calls can still be transformed into those of other functions.
>> -   { dg-skip-if "requires io" { freestanding } } */
>> +   { dg-skip-if "requires io" { freestanding } }
>> +   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used unsafely; consider using \[^\n\]*\n" } */
> 
> I'm worried about that (^|\n) at the start + \n at the end, doesn't it prune
> too much then?
> Looking at other tests, they dg-prune-output just a few words from a
> message, or .*few words.*
> So, can you try just
>     { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; consider using" } */
> or if that doesn't work, with .* at start end end?

Ok, yes it works too with your suggestion.

Attached.

One question, doing it per test case is cheaper than in prune.exp? 
(Where we do it for 'all' test cases, needed or not.)

Thanks,
Andreas



-------------- next part --------------
Index: fprintf-2.c
===================================================================
--- fprintf-2.c	(revision 276292)
+++ fprintf-2.c	(working copy)
@@ -1,7 +1,8 @@
 /* Verify that calls to fprintf don't get eliminated even if their
    result on success can be computed at compile time (they can fail).
    The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; consider using" } */
 
 #include <stdio.h>
 #include <stdlib.h>
Index: printf-2.c
===================================================================
--- printf-2.c	(revision 276292)
+++ printf-2.c	(working copy)
@@ -2,7 +2,8 @@
    result on success can be computed at compile time (they can fail).
    The calls can still be transformed into those of other functions.
    { dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; consider using" } */
 
 #include <stdio.h>
 #include <stdlib.h>
Index: user-printf.c
===================================================================
--- user-printf.c	(revision 276292)
+++ user-printf.c	(working copy)
@@ -2,7 +2,8 @@
    don't get eliminated even if their result on success can be computed at
    compile time (they can fail).
    { dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; consider using" } */
 
 #include <stdarg.h>
 #include <stdio.h>


More information about the Gcc-patches mailing list