From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.c-torture/execute/pr20601-1.c | 122 ++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr20601-1.c (limited to 'gcc/testsuite/gcc.c-torture/execute/pr20601-1.c') diff --git a/gcc/testsuite/gcc.c-torture/execute/pr20601-1.c b/gcc/testsuite/gcc.c-torture/execute/pr20601-1.c new file mode 100644 index 000000000..7c13c9138 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr20601-1.c @@ -0,0 +1,122 @@ +/* PR tree-optimization/20601 */ +extern void abort (void); +extern void exit (int); + +struct T +{ + char *t1; + char t2[4096]; + char **t3; +}; + +int a[5]; +int b; +char **c; +int d; +char **e; +struct T t; +char *f[16]; +char *g[] = { "a", "-u", "b", "c" }; + +__attribute__ ((__noreturn__)) void +foo (void) +{ + while (1); +} + +__attribute__ ((noinline)) char * +bar (char *x, unsigned int y) +{ + return 0; +} + +static inline char * +baz (char *x, unsigned int y) +{ + if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2)) + foo (); + return bar (x, y); +} + +static inline int +setup1 (int x) +{ + char *p; + int rval; + + if (!baz (t.t2, sizeof (t.t2))) + baz (t.t2, sizeof (t.t2)); + + if (x & 0x200) + { + char **h, **i = e; + + ++d; + e = f; + if (t.t1 && *t.t1) + e[0] = t.t1; + else + abort (); + + for (h = e + 1; (*h = *i); ++i, ++h) + ; + } + return 1; +} + +static inline int +setup2 (void) +{ + int j = 1; + + e = c + 1; + d = b - 1; + while (d > 0 && e[0][0] == '-') + { + if (e[0][1] != '\0' && e[0][2] != '\0') + abort (); + + switch (e[0][1]) + { + case 'u': + if (!e[1]) + abort (); + + t.t3 = &e[1]; + d--; + e++; + break; + case 'P': + j |= 0x1000; + break; + case '-': + d--; + e++; + if (j == 1) + j |= 0x600; + return j; + } + d--; + e++; + } + + if (d > 0 && !(j & 1)) + abort (); + + return j; +} + +int +main (void) +{ + int x; + c = g; + b = 4; + x = setup2 (); + t.t1 = "/bin/sh"; + setup1 (x); + /* PRE shouldn't transform x into the constant 0x601 here, it's not legal. */ + if ((x & 0x400) && !a[4]) + abort (); + exit (0); +} -- cgit v1.2.3