patches/gcc/3.3.1/pr10412-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... :-(
yann@1
     1
--- /dev/null	Sat Dec 14 13:56:51 2002
yann@1
     2
+++ gcc-3.3.1/gcc/testsuite/gcc.dg/pr10412-1.c	Sun Sep 14 16:15:21 2003
yann@1
     3
@@ -0,0 +1,43 @@
yann@1
     4
+/* PR target/10412
yann@1
     5
+ * Reporter: shrinivasa@kpitcummins.com 
yann@1
     6
+ * Summary: Renesas SH - Incorrect code generation
yann@1
     7
+ * Description:
yann@1
     8
+ * When following code is compiled  with
yann@1
     9
+ * sh-elf-gcc  -S -mhitachi -m2 -O2 bug1.c
yann@1
    10
+ * generates an incorrect code.
yann@1
    11
+ *
yann@1
    12
+ * Testcase tweaked by dank@kegel.com
yann@1
    13
+ * Problem only happens with -mhitachi -m2.  Not sure if I can give those
yann@1
    14
+ * options for all sh targets.  They work on sh4, though.
yann@1
    15
+ * Not marked as xfail as it's a regression relative to hardhat 2.0 gcc-2.97.
yann@1
    16
+*/
yann@1
    17
+/* { dg-do run } */
yann@1
    18
+/* { dg-options "-O2" } */
yann@1
    19
+int global_val;
yann@1
    20
+
yann@1
    21
+int func0(int x)
yann@1
    22
+{
yann@1
    23
+	global_val += x;
yann@1
    24
+	return (x != 99);
yann@1
    25
+}
yann@1
    26
+
yann@1
    27
+int func1(unsigned long addr)
yann@1
    28
+{
yann@1
    29
+	int err;
yann@1
    30
+
yann@1
    31
+	err = func0(addr);
yann@1
    32
+	if (err)
yann@1
    33
+		return (err);
yann@1
    34
+
yann@1
    35
+	err = func0(addr * 7);	/* address of func0 is lost during multiplication -> probable SIGSEGV */
yann@1
    36
+	return (err);
yann@1
    37
+}
yann@1
    38
+
yann@1
    39
+int main(int argc, char **argv)
yann@1
    40
+{
yann@1
    41
+	global_val = 0;
yann@1
    42
+	global_val += func1(99);
yann@1
    43
+	if (global_val != 99 * 8 + 1)
yann@1
    44
+		abort();
yann@1
    45
+	return 0;
yann@1
    46
+}