Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-10-27 Thread Kamil Rytarowski
On 26.10.2019 23:57, Andreas Tobler wrote:
> On 04.10.19 19:04, Jeff Law wrote:
>> On 9/30/19 12:47 PM, Andreas Tobler wrote:
>>> On 30.09.19 20:37, Kamil Rytarowski wrote:
 On 30.09.2019 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?
>
>  Jakub
>

 Please handle the NetBSD specific string too: "warning: tmpnam()
 possibly used unsafely, use mkstemp() or mkdtemp()".

 https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52

>>>
>>> Ok, I think the attached version should also match these cases. Although
>>> untested on NetBSD.
>>> Kamil, if you have cycles, would you mind giving it a run? Thanks!
>>> Andreas
>>>
>> OK assuming Kamil's testing shows that it works.
>
> Kamil, do you have a feedback? If not I'm going to commit by tomorrow.
>
> Andreas

Please go for it.


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-10-26 Thread Andreas Tobler

On 04.10.19 19:04, Jeff Law wrote:

On 9/30/19 12:47 PM, Andreas Tobler wrote:

On 30.09.19 20:37, Kamil Rytarowski wrote:

On 30.09.2019 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?

 Jakub



Please handle the NetBSD specific string too: "warning: tmpnam()
possibly used unsafely, use mkstemp() or mkdtemp()".

https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52



Ok, I think the attached version should also match these cases. Although
untested on NetBSD.
Kamil, if you have cycles, would you mind giving it a run? Thanks!
Andreas


OK assuming Kamil's testing shows that it works.


Kamil, do you have a feedback? If not I'm going to commit by tomorrow.

Andreas


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-10-04 Thread Jeff Law
On 9/30/19 12:47 PM, Andreas Tobler wrote:
> On 30.09.19 20:37, Kamil Rytarowski wrote:
>> On 30.09.2019 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?
>>>
>>> Jakub
>>>
>>
>> Please handle the NetBSD specific string too: "warning: tmpnam()
>> possibly used unsafely, use mkstemp() or mkdtemp()".
>>
>> https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52
>>
> 
> Ok, I think the attached version should also match these cases. Although
> untested on NetBSD.
> Kamil, if you have cycles, would you mind giving it a run? Thanks!
> Andreas
> 
OK assuming Kamil's testing shows that it works.

jeff


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Segher Boessenkool
On Mon, Sep 30, 2019 at 07:47:54PM +0200, Jakub Jelinek wrote:
> 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?

Or even just

{ dg-prune-output {(?n)warning: warning: .* possibly used unsafely; consider 
using} } */

(?n) means to match single lines only; . and bracket expressions using ^
will not match newlines if you use it.

("warning: " twice, btw?)


Segher


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

On 30.09.19 20:37, Kamil Rytarowski wrote:

On 30.09.2019 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?

Jakub



Please handle the NetBSD specific string too: "warning: tmpnam()
possibly used unsafely, use mkstemp() or mkdtemp()".

https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52



Ok, I think the attached version should also match these cases. Although 
untested on NetBSD.

Kamil, if you have cycles, would you mind giving it a run? Thanks!
Andreas

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" } */
 
 #include 
 #include 
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" } */
 
 #include 
 #include 
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" } */
 
 #include 
 #include 


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Jakub Jelinek
On Mon, Sep 30, 2019 at 08:31:23PM +0200, Andreas Tobler wrote:
> Ok, yes it works too with your suggestion.
> 
> Attached.

Ok for trunk.

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

IMHO yes, doing it 20 or how many times vs. just 3 times should make a
difference.

> 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 
>  #include 
> 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 
>  #include 
> 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 
>  #include 


Jakub


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Kamil Rytarowski
On 30.09.2019 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?
> 
>   Jakub
> 

Please handle the NetBSD specific string too: "warning: tmpnam()
possibly used unsafely, use mkstemp() or mkdtemp()".

https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

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



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 
 #include 
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 
 #include 
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 
 #include 


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Jakub Jelinek
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?

Jakub


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

On 30.09.19 19:20, Jakub Jelinek wrote:

On Mon, Sep 30, 2019 at 07:15:59PM +0200, Andreas Tobler wrote:

Hi all,

the below patch tries to silence a warning from the FreeBSD libc. This
warning currently makes all the test cases fail where we make use of the
tmpnam() function.

---
/usr/local/bin/ld: /tmp//ccBQaYlC.o: in function `main':
printf-2.c:(.text+0x8d): warning: warning: tmpnam() possibly used unsafely;
consider using mkstemp()
---

With this patch, all the *printf* test cases in the gcc part are now
passing.

What dou you think?


Wouldn't it be better to just dg-prune-output it in the 3 affected tests,
perhaps only for affected targets?


Thanks for the feedback!

This way?

TIA,
Andreas


2019-09-30  Andreas Tobler  

* gcc.c-torture/execute/fprintf-2.c: Silence a FreeBSD libc warning.
* gcc.c-torture/execute/printf-2.c: Likewise.
* gcc.c-torture/execute/user-printf.c: Likewise.


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 "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */ 
 
 #include 
 #include 
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 "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */
 
 #include 
 #include 
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 "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */
 
 #include 
 #include 


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Jakub Jelinek
On Mon, Sep 30, 2019 at 07:15:59PM +0200, Andreas Tobler wrote:
> Hi all,
> 
> the below patch tries to silence a warning from the FreeBSD libc. This
> warning currently makes all the test cases fail where we make use of the
> tmpnam() function.
> 
> ---
> /usr/local/bin/ld: /tmp//ccBQaYlC.o: in function `main':
> printf-2.c:(.text+0x8d): warning: warning: tmpnam() possibly used unsafely;
> consider using mkstemp()
> ---
> 
> With this patch, all the *printf* test cases in the gcc part are now
> passing.
> 
> What dou you think?

Wouldn't it be better to just dg-prune-output it in the 3 affected tests,
perhaps only for affected targets?

Jakub


[PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

Hi all,

the below patch tries to silence a warning from the FreeBSD libc. This 
warning currently makes all the test cases fail where we make use of the 
tmpnam() function.


---
/usr/local/bin/ld: /tmp//ccBQaYlC.o: in function `main':
printf-2.c:(.text+0x8d): warning: warning: tmpnam() possibly used 
unsafely; consider using mkstemp()

---

With this patch, all the *printf* test cases in the gcc part are now 
passing.


What dou you think?

TIA,
Andreas

2019-09-30  Andreas Tobler  

* lib/prune.exp (prune_gcc_output): Silence a FreeBSD libc warning.

Index: lib/prune.exp
===
--- lib/prune.exp   (revision 276342)
+++ lib/prune.exp   (working copy)
@@ -73,6 +73,9 @@
 # Ignore harmless warnings from Xcode 4.0.
 regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact 
unwind for\[^\n\]*" $text "" text


+# Ignore FreeBSD libc warning
+regsub -all "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly 
used unsafely; consider using \[^\n\]*\n" $text "" text

+
 # Call into multiline.exp to handle any multiline output directives.
 set text [handle-multiline-outputs $text]