Message ID | 1573060894-16490-2-git-send-email-egeyar.bagcioglu@oracle.com |
---|---|
State | New |
Headers | show |
Series | Introduce a new GCC option, --record-gcc-command-line | expand |
Hi! On Wed, Nov 06, 2019 at 06:21:33PM +0100, Egeyar Bagcioglu wrote: > gcc/testsuite/ChangeLog: > 2019-11-06 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com> > > * 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
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 <egeyar.bagcioglu@oracle.com> >> >> * 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
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 <egeyar.bagcioglu@oracle.com> >> >> * 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 :)
On 11/7/19 6:17 PM, jose.marchesi@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 <egeyar.bagcioglu@oracle.com> > >> > >> * 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!
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 <http://www.tcl.tk/>, where you can see that "string match" does a glob compare. brgds, H-P
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 <http://www.tcl.tk/>, 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
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 } {