diff mbox

[testsuite] Avoid assuming argc != 0

Message ID 8739b6fczy.fsf@firetop.home
State New
Headers show

Commit Message

Richard Sandiford Jan. 23, 2012, 7:13 p.m. UTC
gcc.c-torture/execute/scal-to-vec1.c uses "argc" as an easy way of injecting
a runtime value into a constructor.  The test goes on to do divide by this
value, so it cannot be zero.

This causes problems on embedded targets that don't provide a command line,
and that instead set argc to 0.

One fix is attached.  Another would be to read from a volatile variable
that has been initialised to 1.  Other possibilities exist too of course.

Tested on mipsisa64-elf.  OK to install?

Richard


gcc/testsuite/
	* gcc.c-torture/execute/scal-to-vec1.c (main): Allow argc to be 0.

Comments

Mike Stump Jan. 23, 2012, 7:25 p.m. UTC | #1
On Jan 23, 2012, at 11:13 AM, Richard Sandiford wrote:
> One fix is attached.  Another would be to read from a volatile variable
> that has been initialised to 1.  Other possibilities exist too of course.
> 
> Tested on mipsisa64-elf.  OK to install?

Ok.  I have a preference for volatile (clearer intent)...
diff mbox

Patch

Index: gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c	2012-01-23 19:05:52.000000000 +0000
+++ gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c	2012-01-23 19:05:59.000000000 +0000
@@ -30,7 +30,7 @@  #define fvec_2 (vector(4, float)){2., 2.
 #define dvec_2 (vector(2, double)){2., 2.}
 
 
-    vector(8, short) v0 = {argc, 1,2,3,4,5,6,7};
+    vector(8, short) v0 = {argc | 1, 1,2,3,4,5,6,7};
     vector(8, short) v1;
 
     vector(4, float) f0 = {1., 2., 3., 4.};