This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Testcases that assume argc != 0


Mark Mitchell <mark@codesourcery.com> writes:
> As I understand it, the goal here is to get the value "1", in such a way 
> as the optimizers do not understand it to be a constant.  So, how about 
> just:
>
>    volatile int one = 1;
>
> ?  This should be forever immune from optimization and seems a 
> relatively simple change.  If that works, and if yu like that approach, 
> it's pre-approved.

OK, thanks.  Here's what I installed after retesting on mipsisa64-elf.

Richard


gcc/testsuite/
	* gcc.c-torture/execute/pr28289.c (one): New variable.
	(main): Use it instead of argc.
	* gcc.c-torture/execute/20060102-1.c (one): New variable.
	(main): Use it instead of argc.

Index: gcc/testsuite/gcc.c-torture/execute/pr28289.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/pr28289.c	(revision 117059)
+++ gcc/testsuite/gcc.c-torture/execute/pr28289.c	(working copy)
@@ -18,10 +18,11 @@ ix86_split_ashr (int mode)
                       : gen_x86_64_shrd) (0);
 }
 
+volatile int one = 1;
 int
-main (int argc, char **argv)
+main (void)
 {
-  ix86_split_ashr (argc);
+  ix86_split_ashr (one);
   return 1;
 }
 
Index: gcc/testsuite/gcc.c-torture/execute/20060102-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20060102-1.c	(revision 117059)
+++ gcc/testsuite/gcc.c-torture/execute/20060102-1.c	(working copy)
@@ -5,11 +5,12 @@ int f(int x)
   return (x >> 31) ? -1 : 1;
 }
 
-int main (int argc)
+volatile int one = 1;
+int main (void)
 {
   /* Test that the function above returns different values for
      different signs.  */
-  if (f(argc) == f(-argc))
+  if (f(one) == f(-one))
     abort ();
   return 0;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]