patches/gcc/3.3.3/pr10392-1-test.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
     1 --- /dev/null	Sat Dec 14 13:56:51 2002
     2 +++ gcc-3.3.1/gcc/testsuite/gcc.dg/pr10392-1.c	Sun Sep 14 14:28:24 2003
     3 @@ -0,0 +1,62 @@
     4 +/* PR optimization/10392
     5 + * Reporter: marcus@mc.pp.se
     6 + * Summary: [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
     7 + * Description:
     8 + * The address calculation of an index operation on an array on the stack 
     9 + * can _under some conditions_ get messed up completely
    10 + *
    11 + * Testcase tweaked by dank@kegel.com
    12 + * Problem only happens with -O2 -m4, so it should only happen on sh4,
    13 + * but what the heck, let's test other architectures, too.
    14 + * Not marked as xfail since it's a regression.
    15 +*/
    16 +/* { dg-do run } */
    17 +/* { dg-options "-O2" } */
    18 +/* { dg-options "-O2 -m4" { target sh4-*-* } } */
    19 +const char *dont_optimize_function_away;
    20 +
    21 +const char *use(const char *str)
    22 +{
    23 +	dont_optimize_function_away = str;
    24 +	if (str[0] != 'v')
    25 +		abort();
    26 +	if (str[1] < '1' || str[1] > '6')
    27 +		abort();
    28 +	if (str[2])
    29 +		abort();
    30 +	return str[2] ? "notused" : "v6";
    31 +}
    32 +
    33 +const char *func(char *a, char *b)
    34 +{
    35 +	char buf[128];
    36 +	unsigned char i;
    37 +	const char *result;
    38 +
    39 +	char *item[] = {
    40 +		"v1",
    41 +		"v2",
    42 +	};
    43 +
    44 +	buf[0] = 'v';
    45 +	buf[1] = '3';
    46 +	buf[2] = 0;
    47 +
    48 +	for (i = 0; i < 2; i++) {
    49 +		/* bug is: following line passes wild pointer to use() on sh4 -O2 */
    50 +		result = use(item[i]);
    51 +
    52 +		use(buf);
    53 +		use(a);
    54 +		use(b);
    55 +		result = use(result);
    56 +	}
    57 +	return result;
    58 +}
    59 +
    60 +int main()
    61 +{
    62 +	func("v4", "v5");
    63 +	return 0;
    64 +}
    65 +