Skip to content

Commit 5d419bc

Browse files
add gcc-dg sources
1 parent fd7aca4 commit 5d419bc

File tree

6,351 files changed

+246024
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,351 files changed

+246024
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* Copyright (C) 2000 Free Software Foundation.
2+
3+
by Alexandre Oliva <[email protected]> */
4+
5+
/* { dg-do run } */
6+
/* { dg-options "-O3" } */
7+
8+
extern void abort (void);
9+
10+
void foo () {} /* unused, but essential to trigger the bug */
11+
12+
int main () {
13+
int i;
14+
/* use asms to prevent optimizations */
15+
/* i = -1; */ asm ("" : "=r" (i) : "0" (-1));
16+
/* i = 1; */ asm ("" : "=r" (i) : "0" (i ? 1 : 2));
17+
if (i != 1)
18+
abort();
19+
return 0;
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Copyright (C) 2000 Free Software Foundation.
2+
3+
by Alexandre Oliva <[email protected]> */
4+
5+
/* { dg-do compile } */
6+
7+
__inline int
8+
foo (int **q) {
9+
return *q && **q;
10+
}
11+
12+
void
13+
bar () {
14+
int **p;
15+
if (foo (p))
16+
do_something ();
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* { dg-do run } */
2+
/* { dg-options "-O3 -fno-strict-aliasing" } */
3+
4+
extern void exit (int);
5+
extern void abort (void);
6+
7+
struct foos { int l; };
8+
int foo;
9+
static struct foos *getfoo(void);
10+
int main (void)
11+
{
12+
struct foos *f = getfoo();
13+
f->l = 1;
14+
foo = 2;
15+
if (f->l == 1)
16+
abort();
17+
exit(0);
18+
}
19+
static struct foos *getfoo(void)
20+
{ return (struct foos *)&foo; }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O2 -g" } */
3+
4+
void foo(register char *p)
5+
{
6+
char c, *q, *sp;
7+
while (1) {
8+
*p++=0;
9+
sp=p+1;
10+
c=*sp;
11+
*p++=0;
12+
}
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O2 -Wall" } */
3+
/* { dg-require-effective-target label_values } */
4+
5+
extern void foo(void *here);
6+
extern inline void bar(void)
7+
{
8+
__label__ here;
9+
foo(&&here);
10+
here:
11+
;
12+
}
13+
14+
void baz(void)
15+
{
16+
bar();
17+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* { dg-do run } */
2+
3+
/* Testcase distilled from glibc's nss_parse_service_list in nss/nsswitch.c
4+
It can't be distilled further. Fails with `-O2' for i[3456]86. */
5+
6+
/* this simulates a bounded-pointer type. */
7+
struct ucharp { unsigned char *v, *l, *h; };
8+
9+
/* this simulates bounded-pointer check prior to pointer dereference. */
10+
#define AREF(var, idx) ((((((((var).v+(idx)) < (var).l) \
11+
|| (((var).v+(idx)+1) > (var).h))) \
12+
&& (__builtin_trap (), 0)), \
13+
(var).v)[(idx)])
14+
15+
struct list
16+
{
17+
struct list *next;
18+
};
19+
20+
struct list *
21+
alloc_list (void)
22+
{
23+
static struct list l;
24+
return &l;
25+
}
26+
27+
int one = 1;
28+
29+
void
30+
foo (struct ucharp cp, struct ucharp lp, struct list **nextp)
31+
{
32+
while (1)
33+
{
34+
struct list *list;
35+
while (AREF (lp, 0) && AREF (cp, AREF (lp, 0)))
36+
++lp.v;
37+
list = alloc_list ();
38+
while (AREF (cp, AREF (lp, 0)))
39+
++lp.v;
40+
if (AREF (lp, 0) == one)
41+
do
42+
++lp.v;
43+
while (AREF (lp, 0) && AREF (cp, AREF (lp, 0)));
44+
/* The above AREF (cp, ...) fails because the pseudo created to
45+
hold cp.v holds garbage, having never been set.
46+
The easiest way to see the problem is to compile wiht `-O2 -da'
47+
then look at *.09.loop. Search for something like this:
48+
49+
Hoisted regno 183 r/o from (mem/s:SI (reg:SI 16 argp) 10)
50+
Replaced reg 91, deleting init_insn (213).
51+
52+
Now, look for the use of reg 91, which has no set. */
53+
54+
*nextp = list;
55+
nextp = &list->next;
56+
if (!*lp.v)
57+
break;
58+
}
59+
}
60+
61+
extern void exit (int);
62+
63+
int
64+
main (void)
65+
{
66+
static unsigned char cp0[] = "\0\0\0\0";
67+
struct ucharp cp = { cp0, cp0, cp0 + sizeof (cp0) };
68+
69+
static unsigned char lp0[] = "\1\1\0\0";
70+
struct ucharp lp = { lp0, lp0, lp0 + sizeof (lp0) };
71+
72+
struct list list;
73+
struct list *nextp = &list;
74+
75+
foo (cp, lp, &nextp);
76+
77+
exit (0);
78+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright (C) 2000 Free Software Foundation.
2+
by William Cohen <[email protected]> */
3+
4+
/* { dg-do compile } */
5+
/* { dg-options "" } */
6+
#include <limits.h>
7+
8+
struct PDATA
9+
{
10+
unsigned int Dummy:(sizeof(int)*CHAR_BIT);
11+
const char* PName;
12+
};
13+
14+
typedef struct PDATA P_DATA;
15+
16+
struct PLAYBOOK {
17+
const char * BookName;
18+
P_DATA Play[0];
19+
};
20+
21+
struct PLAYBOOK playbook =
22+
{
23+
"BookName",
24+
{
25+
{ 1, "PName0" }, /* { dg-warning "(excess elements)|(near initialization)" } */
26+
}
27+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* { dg-do compile { target fpic } } */
2+
/* { dg-options "-O2 -fpic" } */
3+
/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
4+
5+
extern void foo (void *a, double x, double y);
6+
void
7+
bar (void *a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k[6])
8+
{
9+
double l, m, n, o, p;
10+
double q, r, s, t, u;
11+
double x, y, v, w;
12+
double z = 0.5 * j;
13+
double aa;
14+
l = b - 3 * d;
15+
m = 4 * f;
16+
n = f - h;
17+
q = c + 3 * g - i;
18+
r = 2 * (e - 2 * g + i);
19+
s = g - i;
20+
if (l != 0.0)
21+
{
22+
aa = 0.0;
23+
o = (- m + aa);
24+
p = (- m - aa);
25+
if (o > 0.0)
26+
{
27+
x = ((b-h)*o + 3*(d+h)*o + 3*(f-h)*o);
28+
y = ((c-i)*o + 3*(e+i)*o + 3*(g-i)*o);
29+
foo (a, z, w);
30+
foo (a, -z, w);
31+
}
32+
if (p > 0.0)
33+
{
34+
x = ((b+3*f-h)*p + 3*(d-2*f+h)*p + 3*p);
35+
y = ((c+3*g-i)*p + 3*(e-2*g+i)*p + 3*p);
36+
v = x * k[0] + y * k[2];
37+
w = x * k[1] + y * k[3];
38+
foo (a, z, w);
39+
foo (a, - z, w);
40+
}
41+
}
42+
if (q != 0.0)
43+
{
44+
aa = 0.0;
45+
t = (- r + aa) / (2 * q);
46+
u = (- r - aa) / (2 * q);
47+
}
48+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* { dg-do run { target fpic } } */
2+
/* { dg-options "-O2 -fpic" } */
3+
4+
extern void abort (void);
5+
extern void exit (int);
6+
7+
double
8+
foo (void)
9+
{
10+
return (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x3f800000UL }).__d);
11+
}
12+
13+
int
14+
main ()
15+
{
16+
if (foo() != 1.0)
17+
abort ();
18+
exit (0);
19+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* { dg-do run { target fpic } } */
2+
/* { dg-options "-O2 -fpic" } */
3+
/* { dg-require-effective-target alloca } */
4+
5+
extern void abort (void);
6+
extern void exit (int);
7+
8+
void foo (char *x, const char *y, ...)
9+
{
10+
}
11+
12+
double bar (const char *x, long y)
13+
{
14+
return 0.0;
15+
}
16+
17+
typedef __SIZE_TYPE__ size_t;
18+
extern size_t strlen (const char *);
19+
20+
double baz (const char *x)
21+
{
22+
if (x[0] != '\0')
23+
{
24+
char y[6 + strlen (x)];
25+
foo (y, "FOO", x);
26+
return bar (y, 0);
27+
}
28+
29+
return (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x3f800000UL }).__d);
30+
}
31+
32+
int
33+
main ()
34+
{
35+
if (baz("") != 1.0)
36+
abort ();
37+
exit (0);
38+
}

0 commit comments

Comments
 (0)