[v2] testsuite/gdb.base: Make skip test not rely on undefined behaviour.

Message ID 51BEF0F9.6060504@linaro.org
State Accepted
Headers show

Commit Message

Will Newton June 17, 2013, 11:20 a.m.
The skip test currently relies on the order of evaluation of
arguments which is not defined. Use the comma operator where
order is defined instead.

gdb/testsuite/ChangeLog:

2013-06-17  Will Newton  <will.newton@linaro.org>

	* gdb.base/skip.c: Use comma to evaluate results of foo()
	and bar() before passing to baz().
	* gdb.base/skip.c: baz() now takes one argument instead of
	two.
---
 gdb/testsuite/gdb.base/skip.c  | 4 ++--
 gdb/testsuite/gdb.base/skip1.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Changes in v2:
 - Use comma operator instead of addition.

Comments

Tom Tromey June 18, 2013, 4:38 p.m. | #1
>>>>> "Will" == Will Newton <will.newton@linaro.org> writes:

Will> 2013-06-17  Will Newton  <will.newton@linaro.org>
Will> 	* gdb.base/skip.c: Use comma to evaluate results of foo()
Will> 	and bar() before passing to baz().
Will> 	* gdb.base/skip.c: baz() now takes one argument instead of
Will> 	two.

This is ok.  Thanks.

Tom
Pedro Alves June 18, 2013, 5:26 p.m. | #2
On 06/17/2013 12:20 PM, Will Newton wrote:
> 
>  int main()
>  {
> -  return baz(foo(), bar());
> +  return baz((bar(), foo()));
>  }

Could you add a small comment explaining the need for
the extra parens?
Will Newton June 18, 2013, 6:16 p.m. | #3
On 18 June 2013 18:26, Pedro Alves <palves@redhat.com> wrote:
> On 06/17/2013 12:20 PM, Will Newton wrote:
>>
>>  int main()
>>  {
>> -  return baz(foo(), bar());
>> +  return baz((bar(), foo()));
>>  }
>
> Could you add a small comment explaining the need for
> the extra parens?

Applied with this change, thanks!

--
Will Newton
Toolchain Working Group, Linaro

Patch

diff --git a/gdb/testsuite/gdb.base/skip.c b/gdb/testsuite/gdb.base/skip.c
index 565ba93..c4f5535 100644
--- a/gdb/testsuite/gdb.base/skip.c
+++ b/gdb/testsuite/gdb.base/skip.c
@@ -1,10 +1,10 @@ 
 int foo();
 int bar();
-int baz(int, int);
+int baz(int);

 int main()
 {
-  return baz(foo(), bar());
+  return baz((bar(), foo()));
 }

 int foo()
diff --git a/gdb/testsuite/gdb.base/skip1.c b/gdb/testsuite/gdb.base/skip1.c
index 2dab5c3..fe63cd6 100644
--- a/gdb/testsuite/gdb.base/skip1.c
+++ b/gdb/testsuite/gdb.base/skip1.c
@@ -3,7 +3,7 @@  int bar()
   return 1;
 }

-int baz(int a, int b)
+int baz(int a)
 {
-  return a + b;
+  return a + 1;
 }