Re: [PATCH 1/2] Introduce dg-require-target-object-format

2019-11-18 Thread Egeyar Bagcioglu




On 11/14/19 3:51 AM, Hans-Peter Nilsson wrote:

On Thu, 7 Nov 2019, Egeyar Bagcioglu wrote:

On 11/7/19 8:47 AM, Segher Boessenkool wrote:

On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote:

+proc dg-require-target-object-format { args } {
+if { [gcc_target_object_format] == [lindex $args 1] } {
+   return
+}

"==" for strings is dangerous.  Use "eq" or "string equal"?

I see many "string match"es. I will make the change.

Please instead use "string equal".

Code in target-supports-dg.exp is not a trustworthy reference.
I suggest RTFM , where you can see that
"string match" does a glob compare.

brgds, H-P


I added the change to my local copy. Thanks for the correction and for 
the reasoning.


Regards
Egeyar


Re: [PATCH 1/2] Introduce dg-require-target-object-format

2019-11-13 Thread Hans-Peter Nilsson
On Thu, 7 Nov 2019, Egeyar Bagcioglu wrote:
> On 11/7/19 8:47 AM, Segher Boessenkool wrote:
> > On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote:
> > > +proc dg-require-target-object-format { args } {
> > > +if { [gcc_target_object_format] == [lindex $args 1] } {
> > > + return
> > > +}
> > "==" for strings is dangerous.  Use "eq" or "string equal"?
>
> I see many "string match"es. I will make the change.

Please instead use "string equal".

Code in target-supports-dg.exp is not a trustworthy reference.
I suggest RTFM , where you can see that
"string match" does a glob compare.

brgds, H-P


Re: [PATCH 1/2] Introduce dg-require-target-object-format

2019-11-07 Thread Egeyar Bagcioglu




On 11/7/19 6:17 PM, jose.march...@oracle.com wrote:
 
 On 11/7/19 8:47 AM, Segher Boessenkool wrote:

 > Hi!
 >
 > On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote:
 >> gcc/testsuite/ChangeLog:
 >> 2019-11-06  Egeyar Bagcioglu  
 >>
 >>  * lib/target-supports-dg.exp: Define 
dg-require-target-object-format.
 > * lib/target-supports-dg.exp (dg-require-target-object-format): New.
 
 Right, thanks for the correction!
 
 >> +proc dg-require-target-object-format { args } {

 >> +if { [gcc_target_object_format] == [lindex $args 1] } {
 >> + return
 >> +}
 > "==" for strings is dangerous.  Use "eq" or "string equal"?
 
 I see many "string match"es. I will make the change.
 
 Just as a note, though: Why is it dangerous? In C, for example, this

 would be a pointer comparison and consistently fail. In many other
 languages, it is indeed a string comparison and works well.
 
 I am asking also because I see "==" for variable vs literal strings in

 gcc/testsuite/lib. As opposed to C-like languages that consistently
 fail them, these seem to work. If you still think this is dangerous,
 I'd love to know why. Also, if so, someone might want to check the
 library.

Because if the string happens to look like a number Tcl will perform
arithmetic comparison instead of lexicographic comparison, i.e. "01" ==
"1" evaluates to true :)


Oh lovely indeed! I am glad I asked.
Thanks Jose!


Re: [PATCH 1/2] Introduce dg-require-target-object-format

2019-11-07 Thread Jose E. Marchesi

On 11/7/19 8:47 AM, Segher Boessenkool wrote:
> Hi!
>
> On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote:
>> gcc/testsuite/ChangeLog:
>> 2019-11-06  Egeyar Bagcioglu  
>>
>>  * lib/target-supports-dg.exp: Define 
dg-require-target-object-format.
> * lib/target-supports-dg.exp (dg-require-target-object-format): New.

Right, thanks for the correction!

>> +proc dg-require-target-object-format { args } {
>> +if { [gcc_target_object_format] == [lindex $args 1] } {
>> +return
>> +}
> "==" for strings is dangerous.  Use "eq" or "string equal"?

I see many "string match"es. I will make the change.

Just as a note, though: Why is it dangerous? In C, for example, this
would be a pointer comparison and consistently fail. In many other
languages, it is indeed a string comparison and works well.

I am asking also because I see "==" for variable vs literal strings in
gcc/testsuite/lib. As opposed to C-like languages that consistently
fail them, these seem to work. If you still think this is dangerous,
I'd love to know why. Also, if so, someone might want to check the
library.

Because if the string happens to look like a number Tcl will perform
arithmetic comparison instead of lexicographic comparison, i.e. "01" ==
"1" evaluates to true :)


Re: [PATCH 1/2] Introduce dg-require-target-object-format

2019-11-07 Thread Egeyar Bagcioglu

Hi Segher!


On 11/7/19 8:47 AM, Segher Boessenkool wrote:

Hi!

On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote:

gcc/testsuite/ChangeLog:
2019-11-06  Egeyar Bagcioglu  

 * lib/target-supports-dg.exp: Define dg-require-target-object-format.

* lib/target-supports-dg.exp (dg-require-target-object-format): New.


Right, thanks for the correction!


+proc dg-require-target-object-format { args } {
+if { [gcc_target_object_format] == [lindex $args 1] } {
+   return
+}

"==" for strings is dangerous.  Use "eq" or "string equal"?


I see many "string match"es. I will make the change.

Just as a note, though: Why is it dangerous? In C, for example, this 
would be a pointer comparison and consistently fail. In many other 
languages, it is indeed a string comparison and works well.


I am asking also because I see "==" for variable vs literal strings in 
gcc/testsuite/lib. As opposed to C-like languages that consistently fail 
them, these seem to work. If you still think this is dangerous, I'd love 
to know why. Also, if so, someone might want to check the library.


Thanks for the review!

Egeyar



Re: [PATCH 1/2] Introduce dg-require-target-object-format

2019-11-06 Thread Segher Boessenkool
Hi!

On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote:
> gcc/testsuite/ChangeLog:
> 2019-11-06  Egeyar Bagcioglu  
> 
> * lib/target-supports-dg.exp: Define dg-require-target-object-format.

* lib/target-supports-dg.exp (dg-require-target-object-format): New.

> +proc dg-require-target-object-format { args } {
> +if { [gcc_target_object_format] == [lindex $args 1] } {
> + return
> +}

"==" for strings is dangerous.  Use "eq" or "string equal"?


Segher


[PATCH 1/2] Introduce dg-require-target-object-format

2019-11-06 Thread Egeyar Bagcioglu
gcc/testsuite/ChangeLog:
2019-11-06  Egeyar Bagcioglu  

* lib/target-supports-dg.exp: Define dg-require-target-object-format.

---
 gcc/testsuite/lib/target-supports-dg.exp | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports-dg.exp 
b/gcc/testsuite/lib/target-supports-dg.exp
index e1da57a..e923754 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -164,6 +164,17 @@ proc dg-require-dll { args } {
 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
 }
 
+# If this target does not produce the given object format skip this test.
+
+proc dg-require-target-object-format { args } {
+if { [gcc_target_object_format] == [lindex $args 1] } {
+   return
+}
+
+upvar dg-do-what dg-do-what
+set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+}
+
 # If this host does not support an ASCII locale, skip this test.
 
 proc dg-require-ascii-locale { args } {
-- 
1.8.3.1