]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/testsuite: remove definition of true/false from gdb_compiler_info
authorAndrew Burgess <aburgess@redhat.com>
Thu, 9 Jun 2022 15:56:35 +0000 (16:56 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 10 Jun 2022 10:05:33 +0000 (11:05 +0100)
commit80c0a3bf1b949403521d186fc04ed9052ea1d7d4
tree82bfc2f563287d6cbbe7b668084fef009b61004e
parent3abc1d8fe0e09a4ba806d5e2a1902ac45f825ee9
gdb/testsuite: remove definition of true/false from gdb_compiler_info

Since pretty much forever the get_compiler_info function has included
these lines:

    # Most compilers will evaluate comparisons and other boolean
    # operations to 0 or 1.
    uplevel \#0 { set true 1 }
    uplevel \#0 { set false 0 }

These define global variables true (to 1) and false (to 0).

It seems odd to me that these globals are defined in
get_compiler_info, I guess maybe the original thinking was that if a
compiler had different true/false values then we would detect it there
and define true/false differently.

I don't think we should be bundling this logic into get_compiler_info,
it seems weird to me that in order to use $true/$false a user needs to
first call get_compiler_info.

It would be better I think if each test script that wants these
variables just defined them itself, if in the future we did need
different true/false values based on compiler version then we'd just
do:

  if { [test_compiler_info "some_pattern"] } {
    # Defined true/false one way...
  } else {
    # Defined true/false another way...
  }

But given the current true/false definitions have been in place since
at least 1999, I suspect this will not be needed any time soon.

Given that the definitions of true/false are so simple, right now my
suggestion is just to define them in each test script that wants
them (there's not that many).  If we ever did need more complex logic
then we can always add a function in gdb.exp that sets up these
globals, but that seems overkill for now.

There should be no change in what is tested after this commit.
gdb/testsuite/gdb.base/all-bin.exp
gdb/testsuite/gdb.base/eval-skip.exp
gdb/testsuite/gdb.base/exprs.exp
gdb/testsuite/gdb.base/miscexprs.exp
gdb/testsuite/gdb.base/pointers.exp
gdb/testsuite/gdb.base/relational.exp
gdb/testsuite/lib/gdb.exp