diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
86 files changed, 1915 insertions, 50 deletions
diff --git a/gcc/testsuite/gcc.dg/Wno-frame-address.c b/gcc/testsuite/gcc.dg/Wno-frame-address.c index de5a8b8d7bc..e6dfe52038a 100644 --- a/gcc/testsuite/gcc.dg/Wno-frame-address.c +++ b/gcc/testsuite/gcc.dg/Wno-frame-address.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* hppa*-*-* ia64-*-* visium-*-* } } */ +/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* avr-*-* hppa*-*-* ia64-*-* visium-*-* } } */ /* { dg-options "-Werror" } */ /* { dg-additional-options "-mbackchain" { target { s390*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-16.c b/gcc/testsuite/gcc.dg/builtin-object-size-16.c new file mode 100644 index 00000000000..15721e5ce89 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-object-size-16.c @@ -0,0 +1,201 @@ +/* PR 71831 - __builtin_object_size poor results with no optimization + Verify that even without optimization __builtin_object_size returns + a meaningful result for a subset of simple expressins. In cases + where the result could not easily be made to match the one obtained + with optimization the built-in was made to fail instead. */ +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +static int nfails; + +#define TEST_FAILURE(line, obj, type, expect, result) \ + __builtin_printf ("FAIL: line %i: __builtin_object_size(" \ + #obj ", %i) == %zu, got %zu\n", \ + line, type, expect, result), ++nfails + +#define bos(obj, type) __builtin_object_size (obj, type) +#define size(obj, n) ((size_t)n == X ? sizeof *obj : (size_t)n) + +#define test(expect, type, obj) \ + do { \ + if (bos (obj, type) != size (obj, expect)) \ + TEST_FAILURE (__LINE__, obj, type, size (obj, expect), bos (obj, type)); \ + } while (0) + +#define T(r0, r1, r2, r3, obj) \ + do { \ + test (r0, 0, obj); \ + test (r1, 1, obj); \ + test (r2, 2, obj); \ + test (r3, 3, obj); \ + } while (0) + +/* For convenience. Substitute for 'sizeof object' in test cases where + the size can vary from target to target. */ +#define X (size_t)0xdeadbeef + +/* __builtin_object_size checking results are inconsistent for equivalent + expressions (see bug 71831). To avoid having duplicate the inconsistency + at -O0 the built-in simply fails. The results hardcoded in this test + are those obtained with optimization (for easy comparison) but without + optimization the macros below turn them into expected failures . */ +#if __OPTIMIZE__ +# define F0(n) n +# define F1(n) n +# define F2(n) n +# define F3(n) n +#else +# define F0(n) -1 +# define F1(n) -1 +# define F2(n) 0 +# define F3(n) 0 +#endif + +typedef __SIZE_TYPE__ size_t; + +extern char ax[]; +char ax2[]; /* { dg-warning "assumed to have one element" } */ + +extern char a0[0]; +static char a1[1]; +static char a2[2]; +static char a9[9]; + +#if __SIZEOF_SHORT__ == 4 +extern short ia0[0]; +static short ia1[1]; +static short ia9[9]; +#elif __SIZEOF_INT__ == 4 +extern int ia0[0]; +static int ia1[1]; +static int ia9[9]; +#endif + +static char a2x2[2][2]; +static char a3x5[3][5]; + +struct Sx { char n, a[]; } sx; +struct S0 { char n, a[0]; } s0; +struct S1 { char n, a[1]; } s1; +struct S2 { char n, a[2]; } s2; +struct S9 { char n, a[9]; } s9; + +struct S2x2 { char n, a[2][2]; } s2x2; +struct S3x5 { char n, a[3][5]; } s3x5; + +static __attribute__ ((noclone, noinline)) void +test_arrays () +{ + T ( -1, -1, 0, 0, ax); + + T ( 0, 0, 0, 0, a0); + T ( 1, 1, 1, 1, ax2); + + T ( 1, 1, 1, 1, a1); + T ( 2, 2, 2, 2, a2); + T ( 9, 9, 9, 9, a9); + + T ( 0, 0, 0, 0, a0); + T ( 1, 1, 1, 1, ax2); + + T ( 0, 0, 0, 0, ia0); + T ( 4, 4, 4, 4, ia1); + T ( 36, 36, 36, 36, ia9); + + /* Not all results for multidimensional arrays make sense (see + bug 77293). The expected results below simply reflect those + obtained at -O2 (modulo the known limitations at -O1). */ + T ( 4, 4, 4, 4, a2x2); + T ( 4, 4, 4, 4, &a2x2[0]); + T ( 4, 2, 4, 2, &a2x2[0][0]); + T ( 0, F1 (0), 0, 0, &a2x2 + 1); + T ( 2, F1 ( 2), 2, F3 ( 2), &a2x2[0] + 1); + T ( 3, F1 ( 1), 3, F3 ( 3), &a2x2[0][0] + 1); + + T ( 15, 15, 15, 15, a3x5); + T ( 15, 5, 15, 5, &a3x5[0][0] + 0); + T ( 14, F1 ( 4), 14, F3 (14), &a3x5[0][0] + 1); + + T ( 1, 1, 1, 1, a1 + 0); + T ( 0, F1 (0), 0, 0, a1 + 1); + T ( 0, F1 ( 0), 0, 0, &a1 + 1); + /* In the following the offset is out of bounds which makes + the expression undefined. Still, verify that the returned + size is zero (and not some large number). */ + T ( 0, F1 (0), 0, 0, a1 + 2); + + T ( 2, 2, 2, 2, a2 + 0); + T ( 1, F1 ( 1), 1, F3 ( 1), a2 + 1); + T ( 0, F1 ( 0), 0, 0, a2 + 2); +} + +static __attribute__ ((noclone, noinline)) void +test_structs (struct Sx *psx, struct S0 *ps0, struct S1 *ps1, struct S9 *ps9) +{ + /* The expected size of a declared object with a flexible array member + is sizeof sx in all __builtin_object_size types. */ + T ( X, X, X, X, &sx); + + /* The expected size of an unknown object with a flexible array member + is unknown in all __builtin_object_size types. */ + T ( -1, -1, 0, 0, psx); + + /* The expected size of a flexible array member of a declared object + is zero. */ + T ( 0, 0, 0, 0, sx.a); + + /* The expected size of a flexible array member of an unknown object + is unknown. */ + T ( -1, -1, 0, 0, psx->a); + + /* The expected size of a declared object with a zero-length array member + is sizeof sx in all __builtin_object_size types. */ + T ( X, X, X, X, &s0); + + /* The expected size of an unknown object with a zero-length array member + is unknown in all __builtin_object_size types. */ + T ( -1, -1, 0, 0, ps0); + + /* The expected size of a zero-length array member of a declared object + is zero. */ + T ( 0, 0, 0, 0, s0.a); + + /* The expected size of a zero-length array member of an unknown object + is unknown. */ + T ( -1, -1, 0, 0, ps0->a); + + T ( X, X, X, X, &s1); + T ( 1, 1, 1, 1, s1.a); + T ( 0, F1 (0), 0, 0, s1.a + 1); + + /* GCC treats arrays of all sizes that are the last member of a struct + as flexible array members. */ + T ( -1, -1, 0, 0, ps1); + T ( -1, -1, 0, 0, ps1->a); + T ( -1, -1, 0, 0, ps1->a + 1); + + T ( X, X, X, X, &s9); + T ( 9, 9, 9, 9, s9.a); + T ( 9, 9, 9, 9, s9.a + 0); + T ( 8, F1 ( 8), 8, F3 ( 8), s9.a + 1); + T ( 7, F1 ( 7), 7, F3 ( 7), s9.a + 2); + T ( 0, F1 ( 0), 0, F3 ( 0), s9.a + 9); + + /* The following make little sense but see bug 77301. */ + T ( -1, -1, 0, 0, ps9); + T ( -1, -1, 0, 0, ps9->a); + T ( -1, -1, 0, 0, ps9->a + 1); +} + +int +main() +{ + test_arrays (); + + test_structs (&sx, &s0, &s1, &s9); + + if (nfails) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-17.c b/gcc/testsuite/gcc.dg/builtin-object-size-17.c new file mode 100644 index 00000000000..03664d5d9a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-object-size-17.c @@ -0,0 +1,158 @@ +/* PR 71831 - __builtin_object_size poor results with no optimization + Verify that even without optimization __builtin_object_size result + is folded into a constant and dead code that depends on it is + eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -fdump-tree-ssa" } */ + +#define concat(a, b) a ## b +#define CAT(a, b) concat (a, b) + +/* Create a symbol name unique to each tes and object size type. */ +#define SYM(type) CAT (CAT (CAT (failure_on_line_, __LINE__), _type_), type) + +/* References to the following undefined symbol which is unique for each + test case are expected to be eliminated. */ +#define TEST_FAILURE(type) \ + do { \ + extern void SYM (type)(void); \ + SYM (type)(); \ + } while (0) + +#define bos(obj, type) __builtin_object_size (obj, type) +#define size(obj, n) ((size_t)n == X ? sizeof *obj : (size_t)n) + +#define test(expect, type, obj) \ + do { \ + if (bos (obj, type) != size (obj, expect)) \ + TEST_FAILURE (type); \ + } while (0) + +#define FOLD_ALL(r0, r1, r2, r3, obj) \ + do { \ + test (r0, 0, obj); \ + test (r1, 1, obj); \ + test (r2, 2, obj); \ + test (r3, 3, obj); \ + } while (0) + +#define FOLD_0_2(r0, r1, r2, r3, obj) \ + do { \ + test (r0, 0, obj); \ + test (r2, 2, obj); \ + } while (0) + +/* For convenience. Substitute for 'sizeof object' in test cases where + the size can vary from target to target. */ +#define X (size_t)0xdeadbeef + +typedef __SIZE_TYPE__ size_t; + +extern char ax[]; +char ax2[]; /* { dg-warning "assumed to have one element" } */ + +extern char a0[0]; +static char a1[1]; +static char a2[2]; +static char a9[9]; + +#if __SIZEOF_SHORT__ == 4 +extern short ia0[0]; +static short ia1[1]; +static short ia9[9]; +#elif __SIZEOF_INT__ == 4 +extern int ia0[0]; +static int ia1[1]; +static int ia9[9]; +#endif + +static char a2x2[2][2]; +static char a3x5[3][5]; + +struct Sx { char n, a[]; } sx; +struct S0 { char n, a[0]; } s0; +struct S1 { char n, a[1]; } s1; +struct S2 { char n, a[2]; } s2; +struct S9 { char n, a[9]; } s9; + +struct S2x2 { char n, a[2][2]; } s2x2; +struct S3x5 { char n, a[3][5]; } s3x5; + +static __attribute__ ((noclone, noinline)) void +test_arrays () +{ + FOLD_ALL ( 1, 1, 1, 1, ax2); + + FOLD_ALL ( 1, 1, 1, 1, a1); + FOLD_ALL ( 2, 2, 2, 2, a2); + FOLD_ALL ( 9, 9, 9, 9, a9); + + FOLD_ALL ( 0, 0, 0, 0, a0); + FOLD_ALL ( 1, 1, 1, 1, ax2); + + FOLD_ALL ( 0, 0, 0, 0, ia0); + FOLD_ALL ( 4, 4, 4, 4, ia1); + FOLD_ALL ( 36, 36, 36, 36, ia9); + + /* Not all results for multidimensional arrays make sense (see + bug 77293). The expected results below simply reflect those + obtained at -O2 (modulo the known limitations at -O1). */ + FOLD_ALL ( 4, 4, 4, 4, a2x2); + FOLD_ALL ( 4, 4, 4, 4, &a2x2[0]); + FOLD_ALL ( 4, 2, 4, 2, &a2x2[0][0]); + FOLD_0_2 ( 0, F1 (0), 0, 0, &a2x2 + 1); + FOLD_0_2 ( 2, F1 ( 2), 2, F3 ( 2), &a2x2[0] + 1); + FOLD_0_2 ( 3, F1 ( 1), 3, F3 ( 3), &a2x2[0][0] + 1); + + FOLD_ALL ( 15, 15, 15, 15, a3x5); + FOLD_ALL ( 15, 5, 15, 5, &a3x5[0][0] + 0); + FOLD_0_2 ( 14, F1 ( 4), 14, F3 (14), &a3x5[0][0] + 1); + + FOLD_ALL ( 1, 1, 1, 1, a1 + 0); + FOLD_0_2 ( 0, F1 ( 0), 0, 0, &a1 + 1); + FOLD_ALL ( 2, 2, 2, 2, a2 + 0); + FOLD_0_2 ( 1, F1 ( 1), 1, F3 ( 1), a2 + 1); + FOLD_0_2 ( 0, F1 ( 0), 0, 0, a2 + 2); +} + +static __attribute__ ((noclone, noinline)) void +test_structs (void) +{ + /* The expected size of a declared object with a flexible array member + is sizeof sx in all __builtin_object_size types. */ + FOLD_ALL ( X, X, X, X, &sx); + + /* The expected size of a flexible array member of a declared object + is zero. */ + FOLD_ALL ( 0, 0, 0, 0, sx.a); + + /* The expected size of a declared object with a zero-length array member + is sizeof sx in all __builtin_object_size types. */ + FOLD_ALL ( X, X, X, X, &s0); + + /* The expected size of a zero-length array member of a declared object + is zero. */ + FOLD_ALL ( 0, 0, 0, 0, s0.a); + + FOLD_ALL ( X, X, X, X, &s1); + FOLD_ALL ( 1, 1, 1, 1, s1.a); + FOLD_0_2 ( 0, F1 (0), 0, 0, s1.a + 1); + + FOLD_ALL ( X, X, X, X, &s9); + FOLD_ALL ( 9, 9, 9, 9, s9.a); + FOLD_ALL ( 9, 9, 9, 9, s9.a + 0); + FOLD_0_2 ( 8, F1 ( 8), 8, F3 ( 8), s9.a + 1); + FOLD_0_2 ( 7, F1 ( 7), 7, F3 ( 7), s9.a + 2); + FOLD_0_2 ( 0, F1 ( 0), 0, F3 ( 0), s9.a + 9); +} + +int +main() +{ + test_arrays (); + test_structs (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "failure_on_line" "ssa" } } */ diff --git a/gcc/testsuite/gcc.dg/builtins-68.c b/gcc/testsuite/gcc.dg/builtins-68.c index c0cc1ebdcb9..1247394e4d9 100644 --- a/gcc/testsuite/gcc.dg/builtins-68.c +++ b/gcc/testsuite/gcc.dg/builtins-68.c @@ -1,7 +1,7 @@ /* PR middle-end/69780 - [4.9/5/6 Regression] ICE on __builtin_alloca_with_align with small alignment */ -/* { dg-require-effective-target alloca } */ /* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ /* { dg-options "-Wno-long-long" } */ #define CHAR_BIT __CHAR_BIT__ diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c index 8164b44283a..bd024c0542d 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c @@ -1,5 +1,5 @@ /* Test passing scalars by value. This test includes _Complex types - whose real and imaginary parts cannot be used in variable-length + whose real and imaginary parts can be used in variable-length argument lists. */ extern void scalar_by_value_4_x (void); diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c index a4e73c9fdb6..a36a06081f1 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c @@ -13,6 +13,7 @@ test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ +extern void testva##NAME (int n, ...); \ \ void \ check##NAME (TYPE x, TYPE v) \ @@ -62,6 +63,81 @@ testit##NAME (void) \ g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ DEBUG_NL; \ DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##NAME (1, \ + g01##NAME); \ + DEBUG_NL; \ + testva##NAME (2, \ + g01##NAME, g02##NAME); \ + DEBUG_NL; \ + testva##NAME (3, \ + g01##NAME, g02##NAME, g03##NAME); \ + DEBUG_NL; \ + testva##NAME (4, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME); \ + DEBUG_NL; \ + testva##NAME (5, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME); \ + DEBUG_NL; \ + testva##NAME (6, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME); \ + DEBUG_NL; \ + testva##NAME (7, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME); \ + DEBUG_NL; \ + testva##NAME (8, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME); \ + DEBUG_NL; \ + testva##NAME (9, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME); \ + DEBUG_NL; \ + testva##NAME (10, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME); \ + DEBUG_NL; \ + testva##NAME (11, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME); \ + DEBUG_NL; \ + testva##NAME (12, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME); \ + DEBUG_NL; \ + testva##NAME (13, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME); \ + DEBUG_NL; \ + testva##NAME (14, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME); \ + DEBUG_NL; \ + testva##NAME (15, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME); \ + DEBUG_NL; \ + testva##NAME (16, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ DEBUG_FPUTS (" test2: "); \ test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c index e0fa7053996..38b17d50066 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c @@ -65,6 +65,23 @@ test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ check##NAME (x14, 14); \ check##NAME (x15, 15); \ check##NAME (x16, 16); \ +} \ + \ +void \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + va_list ap; \ + if (test_va) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + TYPE t = va_arg (ap, TYPE); \ + check##NAME (t, i+1); \ + } \ + va_end (ap); \ + } \ } #ifndef SKIP_COMPLEX diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c index 2bcfa04872f..866121e5dd3 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c @@ -1,5 +1,5 @@ /* Test function return values. This test includes _Complex types - whose real and imaginary parts cannot be used in variable-length + whose real and imaginary parts can be used in variable-length argument lists. */ extern void scalar_return_4_x (void); diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c index 50305be4d35..11f4688a6d0 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c @@ -1,12 +1,22 @@ #include "compat-common.h" +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + #define T(NAME, TYPE, INITVAL) \ -TYPE g01##NAME; \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ \ extern void init##NAME (TYPE *p, TYPE v); \ extern void checkg##NAME (void); \ extern TYPE test0##NAME (void); \ extern TYPE test1##NAME (TYPE); \ +extern TYPE testva##NAME (int n, ...); \ \ void \ check##NAME (TYPE x, TYPE v) \ @@ -22,6 +32,21 @@ testit##NAME (void) \ DEBUG_FPUTS (#NAME); \ DEBUG_FPUTS (" init: "); \ init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ checkg##NAME (); \ DEBUG_NL; \ DEBUG_FPUTS (#NAME); \ @@ -33,13 +58,35 @@ testit##NAME (void) \ DEBUG_FPUTS (" test1: "); \ rslt = test1##NAME (g01##NAME); \ check##NAME (rslt, g01##NAME); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##NAME (1, g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME); \ + check##NAME (rslt, g05##NAME); \ + rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME); \ + check##NAME (rslt, g09##NAME); \ + rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME, \ + g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, \ + g16##NAME); \ + check##NAME (rslt, g16##NAME); \ + } \ DEBUG_NL; \ } #ifndef SKIP_COMPLEX #ifndef SKIP_COMPLEX_INT T(cc, _Complex char, CINT (0, 1)) -T(cs, _Complex short, CINT (1 + 2)) +T(cs, _Complex short, CINT (1, 2)) #endif T(cf, _Complex float, CDBL (1.0, 2.0)) #endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c index 3c96856975f..3ae0749bab8 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c @@ -2,14 +2,11 @@ #include "compat-common.h" -#ifdef SKIP_VA -const int test_va = 0; -#else -const int test_va = 1; -#endif - #define T(NAME, TYPE, INITVAL) \ -extern TYPE g01##NAME; \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ \ extern void check##NAME (TYPE x, TYPE v); \ \ @@ -23,6 +20,21 @@ void \ checkg##NAME (void) \ { \ check##NAME (g01##NAME, 1+INITVAL); \ + check##NAME (g02##NAME, 2+INITVAL); \ + check##NAME (g03##NAME, 3+INITVAL); \ + check##NAME (g04##NAME, 4+INITVAL); \ + check##NAME (g05##NAME, 5+INITVAL); \ + check##NAME (g06##NAME, 6+INITVAL); \ + check##NAME (g07##NAME, 7+INITVAL); \ + check##NAME (g08##NAME, 8+INITVAL); \ + check##NAME (g09##NAME, 9+INITVAL); \ + check##NAME (g10##NAME, 10+INITVAL); \ + check##NAME (g11##NAME, 11+INITVAL); \ + check##NAME (g12##NAME, 12+INITVAL); \ + check##NAME (g13##NAME, 13+INITVAL); \ + check##NAME (g14##NAME, 14+INITVAL); \ + check##NAME (g15##NAME, 15+INITVAL); \ + check##NAME (g16##NAME, 16+INITVAL); \ } \ \ TYPE \ @@ -35,6 +47,19 @@ TYPE \ test1##NAME (TYPE x01) \ { \ return x01; \ +} \ + \ +TYPE \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ } #ifndef SKIP_COMPLEX diff --git a/gcc/testsuite/gcc.dg/fold-reassoc-2.c b/gcc/testsuite/gcc.dg/fold-reassoc-2.c index 98890b10be3..a334ec6122a 100644 --- a/gcc/testsuite/gcc.dg/fold-reassoc-2.c +++ b/gcc/testsuite/gcc.dg/fold-reassoc-2.c @@ -1,13 +1,13 @@ -/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-original" } */
-
-int foo (int i)
-{
- return (i + 2) - (i + 1);
-}
-int bar (int i)
-{
- return (i + 2) + ~i;
-}
-
-/* { dg-final { scan-tree-dump "return 1;" "original" } } */
+/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int foo (int i) +{ + return (i + 2) - (i + 1); +} +int bar (int i) +{ + return (i + 2) + ~i; +} + +/* { dg-final { scan-tree-dump-times "return 1;" 2 "original" } } */ diff --git a/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c b/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c index 63075c80609..e5e6ade6bbe 100644 --- a/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c +++ b/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c @@ -30,7 +30,7 @@ void test_mismatching_types (const char *msg) /* { dg-begin-multiline-output "" } printf("hello %i", (long)0); ~^ - %ld + %li { dg-end-multiline-output "" } */ } @@ -88,7 +88,7 @@ void test_hex (const char *msg) /* { dg-begin-multiline-output "" } printf("hello \x25\x69", msg); ~~~~^~~~ - %s + \x25s { dg-end-multiline-output "" } */ } @@ -102,7 +102,7 @@ void test_oct (const char *msg) /* { dg-begin-multiline-output "" } printf("hello \045\151", msg); ~~~~^~~~ - %s + \045s { dg-end-multiline-output "" } */ } @@ -121,7 +121,7 @@ void test_multiple (const char *msg) /* { dg-begin-multiline-output "" } printf("prefix" "\x25" "\151" "suffix", ~~~~~~~~^~~~ - %s + \x25" "s { dg-end-multiline-output "" } */ } @@ -267,7 +267,7 @@ void test_non_contiguous_strings (void) /* { dg-begin-multiline-output "" } __builtin_printf(" %" "d ", 0.5); ~~~~^ - %f + %" "f { dg-end-multiline-output "" } */ } diff --git a/gcc/testsuite/gcc.dg/format/miss-7.c b/gcc/testsuite/gcc.dg/format/miss-7.c new file mode 100644 index 00000000000..828b781e0e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/miss-7.c @@ -0,0 +1,36 @@ +/* PR77336 - -Wsuggest-attribute=format warning overly simplistic */ +/* { dg-do compile } */ +/* { dg-options "-Wsuggest-attribute=format" } */ + +#include "format.h" + +const char format[] = "%i"; + +void foo (char *d, unsigned n, va_list va) +{ + (void)&n; + + /* The following calls don't imply that the enclosing function is + a candiate for the format attribute because it uses a string + constant as the format. */ + vsnprintf (d, n, "%i", va); + + vsnprintf (d, n, format, va); + + /* In theory this should not trigger the warning either but GCC + doesn't treat the local static constant the same way as the + global and issues a false positive. + const char fmt[] = "%i"; + vsnprintf (d, n, fmt, va); + */ +} + +void bar (char *d, unsigned n, const char *f, va_list va) +{ + (void)&n; + + /* The following call suggests that the enclosing function might + be a candiate for the format attribute because it doesn't use + a string literal as the format. */ + vsnprintf (d, n, f, va); /* { dg-warning "function .bar. might be a candidate for .gnu_printf. format attribute" } */ +} diff --git a/gcc/testsuite/gcc.dg/format/pr72858.c b/gcc/testsuite/gcc.dg/format/pr72858.c new file mode 100644 index 00000000000..d8d0499b778 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/pr72858.c @@ -0,0 +1,410 @@ +/* { dg-options "-Wformat -fdiagnostics-show-caret" } */ + +#include "format.h" + +/* Various format tests, some containing type mismatches. Verify that for + the type mismatch cases that we offer "good" suggestions. Specifically, + any suggestions should preserve flags characters, field width and precision, + and, if possible, the conversion specifier character, whilst giving a + corrected length modifier appropriate to the argument type. */ + +/* Tests of "x" without a length modifier, with various param types. + Suggestions should preserve the "x" for integer arguments. */ + +void +test_x (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr, + float fexpr, double dexpr, long double ldexpr, + void *ptr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8x ", iexpr); + sprintf (d, " %-8x ", uiexpr); + + sprintf (d, " %-8x ", lexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", lexpr); + ~~~^ + %-8lx + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", ulexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ulexpr); + ~~~^ + %-8lx + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8x ", llexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", llexpr); + ~~~^ + %-8llx + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", ullexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ullexpr); + ~~~^ + %-8llx + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8x ", fexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "fexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", fexpr); + ~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", dexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "dexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", dexpr); + ~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", ldexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ldexpr); + ~~~^ + %-8Lf + { dg-end-multiline-output "" } */ + + /* Pointer. */ + sprintf (d, " %-8x ", ptr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'void \\*'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ptr); + ~~~^ + %-8p + { dg-end-multiline-output "" } */ + + /* Something unrecognized. */ + struct s { int i; }; + struct s s; + sprintf (d, " %-8x ", s); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'struct s'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", s); + ~~~^ + { dg-end-multiline-output "" } */ +} + +/* Tests of "x" with "l", with various param types. + Suggestions should preserve the "x" for integer arguments. */ + +void +test_lx (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr, + float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8lx ", iexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", iexpr); + ~~~~^ + %-8x + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", uiexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int'" } */ +/* TODO: ideally would also underline "uiexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", uiexpr); + ~~~~^ + %-8x + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8lx ", lexpr); + sprintf (d, " %-8lx ", ulexpr); + + sprintf (d, " %-8lx ", llexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "llexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", llexpr); + ~~~~^ + %-8llx + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", ullexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "ullexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", ullexpr); + ~~~~^ + %-8llx + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8lx ", fexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "fexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", fexpr); + ~~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", dexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "dexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", dexpr); + ~~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", ldexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", ldexpr); + ~~~~^ + %-8Lf + { dg-end-multiline-output "" } */ +} + +/* Tests of "o" without a length modifier, with various param types. + Suggestions should preserve the "o" for integer arguments. */ + +void +test_o (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8o ", iexpr); + sprintf (d, " %-8o ", uiexpr); + + sprintf (d, " %-8o ", lexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", lexpr); + ~~~^ + %-8lo + { dg-end-multiline-output "" } */ + sprintf (d, " %-8o ", ulexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", ulexpr); + ~~~^ + %-8lo + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8o ", llexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", llexpr); + ~~~^ + %-8llo + { dg-end-multiline-output "" } */ + sprintf (d, " %-8o ", ullexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", ullexpr); + ~~~^ + %-8llo + { dg-end-multiline-output "" } */ +} + +/* Tests of "o" with "l", with various param types. + Suggestions should preserve the "o" for integer arguments. */ + +void +test_lo (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8lo ", iexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", iexpr); + ~~~~^ + %-8o + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lo ", uiexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int'" } */ +/* TODO: ideally would also underline "uiexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", uiexpr); + ~~~~^ + %-8o + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8lo ", lexpr); + sprintf (d, " %-8lo ", ulexpr); + + sprintf (d, " %-8lo ", llexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "llexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", llexpr); + ~~~~^ + %-8llo + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lo ", ullexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "ullexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", ullexpr); + ~~~~^ + %-8llo + { dg-end-multiline-output "" } */ +} + +/* Tests of "e" without a length modifier, with various param types. + Suggestions should preserve the "e" for float arguments. */ + +void +test_e (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8e ", iexpr); /* { dg-warning "20: format '%e' expects argument of type 'double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8e ", iexpr); + ~~~^ + %-8d + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8e ", fexpr); + sprintf (d, " %-8e ", dexpr); + sprintf (d, " %-8e ", ldexpr); /* { dg-warning "20: format '%e' expects argument of type 'double', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8e ", ldexpr); + ~~~^ + %-8Le + { dg-end-multiline-output "" } */ +} + +/* Tests of "e" with "L", with various param types. + Suggestions should preserve the "e" for float arguments. */ + +void +test_Le (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8Le ", iexpr); /* { dg-warning "21: format '%Le' expects argument of type 'long double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8Le ", iexpr); + ~~~~^ + %-8d + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8Le ", fexpr); /* { dg-warning "21: format '%Le' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8Le ", fexpr); + ~~~~^ + %-8e + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8Le ", dexpr); /* { dg-warning "21: format '%Le' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8Le ", dexpr); + ~~~~^ + %-8e + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8Le ", ldexpr); +} + +/* Tests of "E" without a length modifier, with various param types. + Suggestions should preserve the "E" for floating-point arguments. */ + +void +test_E (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8E ", iexpr); /* { dg-warning "20: format '%E' expects argument of type 'double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8E ", iexpr); + ~~~^ + %-8d + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8E ", fexpr); + sprintf (d, " %-8E ", dexpr); + sprintf (d, " %-8E ", ldexpr); /* { dg-warning "20: format '%E' expects argument of type 'double', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8E ", ldexpr); + ~~~^ + %-8LE + { dg-end-multiline-output "" } */ +} + +/* Tests of "E" with "L", with various param types. + Suggestions should preserve the "E" for floating-point arguments. */ + +void +test_LE (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8LE ", iexpr); /* { dg-warning "21: format '%LE' expects argument of type 'long double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8LE ", iexpr); + ~~~~^ + %-8d + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8LE ", fexpr); /* { dg-warning "21: format '%LE' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8LE ", fexpr); + ~~~~^ + %-8E + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8LE ", dexpr); /* { dg-warning "21: format '%LE' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8LE ", dexpr); + ~~~~^ + %-8E + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8LE ", ldexpr); +} + +/* Test of a suggestion for a conversion specification containing + all features (flags, width, precision, length modifier), where + all the other arguments have mismatching types. */ + +void +test_everything (char *d, long lexpr) +{ + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); /* { dg-warning "26: field width specifier '\\*' expects argument of type 'int', but argument 3 has type 'long int'" } */ + /* { dg-begin-multiline-output "" } + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); + ~~~^~~~~~ + { dg-end-multiline-output "" } */ + + /* { dg-warning "28: field precision specifier '\\.\\*' expects argument of type 'int', but argument 4 has type 'long int'" "" { target *-*-* } 392 } */ + /* { dg-begin-multiline-output "" } + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); + ~~~~~^~~~ + { dg-end-multiline-output "" } */ + + /* { dg-warning "31: format '%lld' expects argument of type 'long long int', but argument 5 has type 'long int'" "" { target *-*-* } 392 } */ + /* { dg-begin-multiline-output "" } + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); + ~~~~~~~~^ + %-+*.*ld + { dg-end-multiline-output "" } */ +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-1.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-1.c new file mode 100644 index 00000000000..1f784524f67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-1.c @@ -0,0 +1,103 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +_Atomic int t; +#pragma omp threadprivate (t) + +void +foo (void) +{ + _Atomic int a = 4, b = 0, c, d = 3, e; + a++; + #pragma omp parallel sections num_threads (a) shared (b) private (c) firstprivate (d) lastprivate (e) + { + #pragma omp section + { + a++; + b++; + c = 5; + c++; + d++; + e = 9; + e++; + } + #pragma omp section + { + a++; + b++; + c = 5; + c++; + d++; + e = 3; + e++; + } + } + e++; + t++; + #pragma omp parallel copyin (t) private (e) + { + t++; + e = t; + #pragma omp single copyprivate (e) + { + e++; + } + e++; + } +} + +void +bar (void) +{ + int a[4]; + _Atomic int b = 1, c = 2, f = 8, g = 8, h = 0; + _Atomic int d, e[3]; + int *_Atomic p; + _Atomic int *_Atomic q; + int i, j; + p = a; + q = e; + #pragma omp target teams map (tofrom: a[b:c]) num_teams (b) thread_limit (c) + a[1]++; + #pragma omp target device(h) + ; + #pragma omp task depend (inout: a[b:c]) + ; + #pragma omp task depend (out: d, e[b:c]) priority (b) + ; + #pragma omp task depend (out: p[b:c]) + ; + #pragma omp task depend (out: q[b:c]) + ; + #pragma omp taskloop num_tasks (c) + for (i = 0; i < 16; i++) + ; + #pragma omp taskloop grainsize (c) + for (i = 0; i < 16; i++) + ; + #pragma omp parallel for schedule (dynamic, b) + for (i = 0; i < 16; i++) + ; + j = 0; + #pragma omp simd linear(j:b) + for (i = 0; i < 16; i++) + j += b; + j = 4; + #pragma omp atomic read + b = j; + #pragma omp atomic write + j = c; + #pragma omp atomic + j += c; + #pragma omp atomic capture + b = j += c; + #pragma omp atomic capture + b = ++j; + #pragma omp atomic capture + { b = j; j = c; } + #pragma omp atomic capture + { b = j; j++; } + #pragma omp atomic capture + { j *= c; b = j; } +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-2.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-2.c new file mode 100644 index 00000000000..159a5b3ee7d --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-2.c @@ -0,0 +1,76 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +void +f1 (void) +{ + _Atomic int i; + #pragma omp for /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp parallel for /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp parallel for simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp for simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp for /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp parallel for /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp parallel for simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp for simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; +} + +void +f2 (void) +{ + _Atomic int i; + #pragma omp distribute /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp distribute parallel for /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp distribute parallel for simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp distribute /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp distribute parallel for /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp distribute parallel for simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; +} + +void +f3 (void) +{ + int i; + _Atomic int j = 0; + #pragma omp simd linear(j:2) /* { dg-error "'_Atomic' 'j' in 'linear' clause" } */ + for (i = 0; i < 64; i++) + j += 2; + #pragma omp parallel for linear(j:1) /* { dg-error "'_Atomic' 'j' in 'linear' clause" } */ + for (i = 0; i < 64; i++) + j++; +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-3.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-3.c new file mode 100644 index 00000000000..31dd1cb1122 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-3.c @@ -0,0 +1,65 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +void +f1 (void) +{ + _Atomic int i = 0, k[4]; + int j = 0; + k[0] = 0; + k[1] = 0; + k[2] = 0; + k[3] = 0; + #pragma omp parallel reduction (+:i) /* { dg-error "'_Atomic' 'i' in 'reduction' clause" } */ + i++; + #pragma omp declare reduction (foo: _Atomic int: omp_out += omp_in) initializer (omp_priv = omp_orig * 0) /* { dg-error "'_Atomic' qualified type in '#pragma omp declare reduction'" } */ + #pragma omp declare reduction (bar: int: omp_out += omp_in) initializer (omp_priv = omp_orig * 0) + #pragma omp parallel reduction (bar:j) + j++; + #pragma omp parallel reduction (bar:i) /* { dg-error "'_Atomic' 'i' in 'reduction' clause" } */ + i++; + #pragma omp parallel reduction (+:k) /* { dg-error "'_Atomic' 'k' in 'reduction' clause" } */ + k[1]++; + #pragma omp parallel reduction (+:k[1:2]) /* { dg-error "'_Atomic' \[^\n\r]* in 'reduction' clause" } */ + k[1]++; +} + +void +f2 (int *_Atomic p) +{ + #pragma omp simd aligned (p : 16) /* { dg-error "'_Atomic' 'p' in 'aligned' clause" } */ + for (int i = 0; i < 16; i++) + p[i]++; +} + +_Atomic int x; + +void +f3 (_Atomic int *p) +{ + int i; + #pragma omp atomic write + x = 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic read + i = x; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic update + x += 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic capture + i = x *= 2; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic write + p[2] = 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic read + i = p[2]; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic update + p[2] += 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic capture + i = p[2] *= 2; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ +} + +#pragma omp declare simd linear(x:1) /* { dg-error "'_Atomic' 'x' in 'linear' clause" } */ +int +f4 (_Atomic int x, int y) +{ + return x + y; +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-4.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-4.c new file mode 100644 index 00000000000..f790dd094dc --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-4.c @@ -0,0 +1,18 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ +/* { dg-require-effective-target vect_simd_clones } */ + +#pragma omp declare simd +int +f1 (_Atomic int x, int y) /* { dg-warning "ignoring '#pragma omp declare simd' on function with '_Atomic' qualified non-'uniform' argument" } */ +{ + return x + y; +} + +#pragma omp declare simd uniform(x) +int +f2 (_Atomic int x, int y) +{ + return x + y; +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-5.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-5.c new file mode 100644 index 00000000000..9b7f58f0329 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-5.c @@ -0,0 +1,74 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +void +f1 (void) +{ + struct S { int a; int b[2]; _Atomic int *c; }; + _Atomic int a = 0, b[2]; + _Atomic int d[3]; + _Atomic struct S c = (struct S) { 3, { 4, 5 }, d }; + int *_Atomic p; + _Atomic int *q; + int e[3] = { 1, 2, 3 }; + b[0] = 1; + b[1] = 2; + d[0] = 6; + d[1] = 7; + d[2] = 8; + p = e; + #pragma omp target map(tofrom: a) /* { dg-error "'_Atomic' 'a' in 'map' clause" } */ + ; + #pragma omp target map(to: b) /* { dg-error "'_Atomic' 'b' in 'map' clause" } */ + ; + #pragma omp target map(from: b[1:1]) /* { dg-error "'_Atomic' 'b' in 'map' clause" } */ + ; + #pragma omp target map(to: c.a) /* { dg-error "'_Atomic' 'c.a' in 'map' clause" } */ + /* { dg-warning "accessing a member 'a' of an atomic structure 'c'" "" { target *-*-* } 27 } */ + ; + #pragma omp target map(to: c.b[1]) /* { dg-error "'_Atomic' 'c.b' in 'map' clause" } */ + /* { dg-warning "accessing a member 'b' of an atomic structure 'c'" "" { target *-*-* } 30 } */ + ; + #pragma omp target data map(c) /* { dg-error "'_Atomic' 'c' in 'map' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 33 } */ + { + #pragma omp target update to (c.a) /* { dg-error "'_Atomic' 'c.a' in 'to' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 36 } */ + /* { dg-warning "accessing a member 'a' of an atomic structure 'c'" "" { target *-*-* } 36 } */ + #pragma omp target update from (c.b[1]) /* { dg-error "'_Atomic' 'c.b' in 'from' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 39 } */ + /* { dg-warning "accessing a member 'b' of an atomic structure 'c'" "" { target *-*-* } 39 } */ + #pragma omp target update to (c) /* { dg-error "'_Atomic' 'c' in 'to' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 42 } */ + } + #pragma omp target map(to: c.c[0:]) /* { dg-error "'_Atomic' 'c.c' in 'map' clause" } */ + /* { dg-warning "accessing a member 'c' of an atomic structure 'c'" "" { target *-*-* } 45 } */ + ; + #pragma omp target map(to: p[1:2]) /* { dg-error "'_Atomic' 'p' in 'map' clause" } */ + ; + #pragma omp target map(to: q[1:2]) /* { dg-error "'_Atomic' '\[^\n\r]*' in 'map' clause" } */ + ; +} + +void +f2 (void) +{ + _Atomic int a = 0, b[2] = { 1, 2 }; + #pragma omp target defaultmap(tofrom:scalar) /* { dg-error "'_Atomic' 'a' in implicit 'map' clause" } */ + a++; + #pragma omp target /* { dg-error "'_Atomic' 'b' in implicit 'map' clause" } */ + b[0]++; +} + +void +f3 (void) +{ + _Atomic int a = 0, b[2] = { 1, 2 }; + #pragma omp target /* { dg-error "'_Atomic' 'a' in implicit 'firstprivate' clause on 'target' construct" } */ + a++; + #pragma omp target firstprivate (a) /* { dg-error "'_Atomic' 'a' in 'firstprivate' clause on 'target' construct" } */ + a++; + #pragma omp target firstprivate (b) /* { dg-error "'_Atomic' 'b' in 'firstprivate' clause on 'target' construct" } */ + b[0]++; +} diff --git a/gcc/testsuite/gcc.dg/ipa/pr63416.c b/gcc/testsuite/gcc.dg/ipa/pr63416.c new file mode 100644 index 00000000000..b5374c51fe9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr63416.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define _UNUSED_ __attribute__((__unused__)) + +typedef int TEST_F30 (int *v); +typedef void TEST_F31 (int *v); +typedef void TEST_F32 (int *v, int r); + +typedef struct TEST_T30_ { + TEST_F30 * pf30; + TEST_F31 * pf31; + TEST_F32 * pf32; +} TEST_T30; + +static inline +int test_f30 (int *v) +{ + *v = 1; + return 0; +}//test_f30() + +static inline +void test_f31 (int *v _UNUSED_) +{ +}//test_f31() + +static inline +void test_f32 (int *v, int r _UNUSED_) +{ + *v = 0; +}//test_f32() + +static const +TEST_T30 test_t30 = { + .pf30 = test_f30, + .pf31 = test_f31, + .pf32 = test_f32, +}; + +static inline +int test_f10 (const TEST_T30 *pt30, int *v) +{ + int r = pt30->pf30(v); + pt30->pf31(v); + pt30->pf32(v, r); + return 0; +}//test_f10() + +int test_f00 (int *v) +{ + return test_f10(&test_t30, v); +}//test_f00() + +/* Everything should be inlined and only test_f00 body should appear. */ +/* { dg-final { scan-tree-dump-not "test_f10" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "test_f3" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/limits-width-1.c b/gcc/testsuite/gcc.dg/limits-width-1.c new file mode 100644 index 00000000000..7a87014526c --- /dev/null +++ b/gcc/testsuite/gcc.dg/limits-width-1.c @@ -0,0 +1,55 @@ +/* Test TS 18661-1 width macros in <limits.h>. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include <limits.h> + +#define CHECK_WIDTH(TYPE, MAX, WIDTH) \ + _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \ + "width must match type") + +#ifndef CHAR_WIDTH +# error "missing CHAR_WIDTH" +#endif +CHECK_WIDTH (char, CHAR_MAX, CHAR_WIDTH); +#ifndef SCHAR_WIDTH +# error "missing SCHAR_WIDTH" +#endif +CHECK_WIDTH (signed char, SCHAR_MAX, SCHAR_WIDTH); +#ifndef UCHAR_WIDTH +# error "missing UCHAR_WIDTH" +#endif +CHECK_WIDTH (unsigned char, UCHAR_MAX, UCHAR_WIDTH); +#ifndef SHRT_WIDTH +# error "missing SHRT_WIDTH" +#endif +CHECK_WIDTH (signed short, SHRT_MAX, SHRT_WIDTH); +#ifndef USHRT_WIDTH +# error "missing USHRT_WIDTH" +#endif +CHECK_WIDTH (unsigned short, USHRT_MAX, USHRT_WIDTH); +#ifndef INT_WIDTH +# error "missing INT_WIDTH" +#endif +CHECK_WIDTH (signed int, INT_MAX, INT_WIDTH); +#ifndef UINT_WIDTH +# error "missing UINT_WIDTH" +#endif +CHECK_WIDTH (unsigned int, UINT_MAX, UINT_WIDTH); +#ifndef LONG_WIDTH +# error "missing LONG_WIDTH" +#endif +CHECK_WIDTH (signed long, LONG_MAX, LONG_WIDTH); +#ifndef ULONG_WIDTH +# error "missing ULONG_WIDTH" +#endif +CHECK_WIDTH (unsigned long, ULONG_MAX, ULONG_WIDTH); +#ifndef LLONG_WIDTH +# error "missing LLONG_WIDTH" +#endif +CHECK_WIDTH (signed long long, LLONG_MAX, LLONG_WIDTH); +#ifndef ULLONG_WIDTH +# error "missing ULLONG_WIDTH" +#endif +CHECK_WIDTH (unsigned long long, ULLONG_MAX, ULLONG_WIDTH); diff --git a/gcc/testsuite/gcc.dg/march-generic.c b/gcc/testsuite/gcc.dg/march-generic.c index 6b0923919e3..fb5b83c7d74 100644 --- a/gcc/testsuite/gcc.dg/march-generic.c +++ b/gcc/testsuite/gcc.dg/march-generic.c @@ -1,6 +1,6 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ /* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */ /* { dg-options "-march=generic" } */ -/* { dg-error "generic CPU can be used only for -mtune" "" { target *-*-* } 0 } */ +/* { dg-error "'generic' CPU can be used only for '-mtune=' switch" "" { target *-*-* } 0 } */ /* { dg-bogus "march" "" { target *-*-* } 0 } */ int i; diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c new file mode 100644 index 00000000000..afbaf635401 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c @@ -0,0 +1,77 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdiagnostics-generate-patch" } */ + +/* This is a collection of unittests for diagnostic_show_locus; + see the overview in diagnostic_plugin_test_show_locus.c. + + In particular, note the discussion of why we need a very long line here: +01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + and that we can't use macros in this file. */ + +/* Unit test for rendering of insertion fixit hints + (example taken from PR 62316). */ + +void test_fixit_insert (void) +{ +#if 0 + int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */ +#endif +} + +/* Unit test for rendering of "remove" fixit hints. */ + +void test_fixit_remove (void) +{ +#if 0 + int a;; /* { dg-warning "example of a removal hint" } */ +#endif +} + +/* Unit test for rendering of "replace" fixit hints. */ + +void test_fixit_replace (void) +{ +#if 0 + gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */ +#endif +} + + + +/* Verify the output from -fdiagnostics-generate-patch. + We expect a header, containing the filename. This is the absolute path, + so we can only capture it via regexps. */ + +/* { dg-regexp "\\-\\-\\- .*" } */ +/* { dg-regexp "\\+\\+\\+ .*" } */ + +/* Next, we expect the diff itself. */ +/* { dg-begin-multiline-output "" } +@@ -14,7 +14,7 @@ + void test_fixit_insert (void) + { + #if 0 +- int a[2][2] = { 0, 1 , 2, 3 }; ++ int a[2][2] = { {0, 1} , 2, 3 }; + #endif + } + +@@ -23,7 +23,7 @@ + void test_fixit_remove (void) + { + #if 0 +- int a;; ++ int a; + #endif + } + +@@ -32,7 +32,7 @@ + void test_fixit_replace (void) + { + #if 0 +- gtk_widget_showall (dlg); ++ gtk_widget_show_all (dlg); + #endif + } + + { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c index ea28f046e8d..3efc7dfa0b4 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c @@ -263,8 +263,8 @@ test_show_locus (function *fun) location_t start = get_loc (line, 19); location_t finish = get_loc (line, 22); rich_location richloc (line_table, make_location (start, start, finish)); - richloc.add_fixit_insert (start, "{"); - richloc.add_fixit_insert (get_loc (line, 23), "}"); + richloc.add_fixit_insert_before ("{"); + richloc.add_fixit_insert_after ("}"); warning_at_rich_loc (&richloc, 0, "example of insertion hints"); } diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c index dff999c3aa9..99a504dc541 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c @@ -33,6 +33,7 @@ #include "print-tree.h" #include "cpplib.h" #include "c-family/c-pragma.h" +#include "substring-locations.h" int plugin_is_GPL_compatible; diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index 715038a0279..32ca748e2cb 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -65,7 +65,8 @@ set plugin_test_list [list \ { diagnostic_plugin_test_show_locus.c \ diagnostic-test-show-locus-bw.c \ diagnostic-test-show-locus-color.c \ - diagnostic-test-show-locus-parseable-fixits.c } \ + diagnostic-test-show-locus-parseable-fixits.c \ + diagnostic-test-show-locus-generate-patch.c } \ { diagnostic_plugin_test_tree_expression_range.c \ diagnostic-test-expressions-1.c } \ { diagnostic_plugin_show_trees.c \ diff --git a/gcc/testsuite/gcc.dg/pr64252.c b/gcc/testsuite/gcc.dg/pr64252.c index 71f9c7812a4..a813f5aedc4 100644 --- a/gcc/testsuite/gcc.dg/pr64252.c +++ b/gcc/testsuite/gcc.dg/pr64252.c @@ -1,6 +1,7 @@ /* PR target/64252 */ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* { dg-require-effective-target int32plus } */ typedef unsigned int V __attribute__((vector_size (32))); diff --git a/gcc/testsuite/gcc.dg/pr66299-1.c b/gcc/testsuite/gcc.dg/pr66299-1.c index e75146bf3eb..df8476462f9 100644 --- a/gcc/testsuite/gcc.dg/pr66299-1.c +++ b/gcc/testsuite/gcc.dg/pr66299-1.c @@ -1,6 +1,7 @@ /* PR tree-optimization/66299 */ /* { dg-do run } */ /* { dg-options "-fdump-tree-original" } */ +/* { dg-require-effective-target int32plus } */ void test1 (int x) diff --git a/gcc/testsuite/gcc.dg/pr66299-2.c b/gcc/testsuite/gcc.dg/pr66299-2.c index 45e92184764..c75c539a41f 100644 --- a/gcc/testsuite/gcc.dg/pr66299-2.c +++ b/gcc/testsuite/gcc.dg/pr66299-2.c @@ -1,6 +1,7 @@ /* PR tree-optimization/66299 */ /* { dg-do run } */ /* { dg-options "-fdump-tree-optimized -O" } */ +/* { dg-require-effective-target int32plus } */ void test1 (int x, unsigned u) diff --git a/gcc/testsuite/gcc.dg/pr77450.c b/gcc/testsuite/gcc.dg/pr77450.c new file mode 100644 index 00000000000..7c19e86ca02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77450.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +typedef int V __attribute__((vector_size(4))); + +void +foo(void) +{ + (V){ 0 }[0] = 0; +} diff --git a/gcc/testsuite/gcc.dg/pr77454.c b/gcc/testsuite/gcc.dg/pr77454.c new file mode 100644 index 00000000000..1bb41c2b176 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77454.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/77454 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (unsigned char x, char y) +{ + while (x != 0) + { + unsigned char *a = &x; + int b; + + if (y != 0) + a = (unsigned char *) &y; + else if (y + 1 != 0) + a = (unsigned char *) &y; + for (x = 0; x < 1; ++x) + b = 0; + for (y = 0; y < 3; ++y) + { + y = !!y; + if (y != 0) + x = y; + } + if ((b != 0 ? -1 : *a) < (y = b)) + b = 1; + } +} diff --git a/gcc/testsuite/gcc.dg/pr77520.c b/gcc/testsuite/gcc.dg/pr77520.c new file mode 100644 index 00000000000..b237639fb20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77520.c @@ -0,0 +1,10 @@ +/* PR c/77520 - wrong value for extended ASCII characters in -Wformat message + Verify that characters in the extended ASCII range are quoted and not + allowed to be printed raw. */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void f (void) +{ + __builtin_printf ("%\x80"); /* { dg-warning "unknown conversion type character .\\\\x80. in format" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr77521.c b/gcc/testsuite/gcc.dg/pr77521.c new file mode 100644 index 00000000000..f6b1e3ed269 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77521.c @@ -0,0 +1,8 @@ +/* PR c/77521 - %qc format directive should quote non-printable characters. + Verify that non-printable characters in assembly constraints are quoted + and not allowed to be printed raw. */ + +void f (int a, int b) +{ + __asm__ ("combine %2, %0" : "=r" (a) : "0" (a), "\n" (b)); /* { dg-error "invalid punctuation .\\\\x0a. in constraint" } */ +} diff --git a/gcc/testsuite/gcc.dg/profile-update-warning.c b/gcc/testsuite/gcc.dg/profile-update-warning.c new file mode 100644 index 00000000000..0614fad960f --- /dev/null +++ b/gcc/testsuite/gcc.dg/profile-update-warning.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fprofile-update=atomic -fprofile-generate -march=i386 -m32" } */ + +int main(int argc, char *argv[]) +{ + return 0; +} /* { dg-warning "target does not support atomic profile update, single mode is selected" } */ diff --git a/gcc/testsuite/gcc.dg/stdint-width-1.c b/gcc/testsuite/gcc.dg/stdint-width-1.c new file mode 100644 index 00000000000..a28feee38db --- /dev/null +++ b/gcc/testsuite/gcc.dg/stdint-width-1.c @@ -0,0 +1,175 @@ +/* Test TS 18661-1 width macros in <stdint.h>. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ffreestanding" } */ + +#include <stddef.h> +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include <stdint.h> +#ifndef SIGNAL_SUPPRESS +#include <signal.h> +#endif +typedef __WINT_TYPE__ wint_t; + +#define CHECK_WIDTH(TYPE, MAX, WIDTH) \ + _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \ + "width must match type") + +#ifdef INT8_MAX +# ifndef INT8_WIDTH +# error "missing INT8_WIDTH" +# endif +CHECK_WIDTH (int8_t, INT8_MAX, INT8_WIDTH); +#endif +#ifdef INT16_MAX +# ifndef INT16_WIDTH +# error "missing INT16_WIDTH" +# endif +CHECK_WIDTH (int16_t, INT16_MAX, INT16_WIDTH); +#endif +#ifdef INT32_MAX +# ifndef INT32_WIDTH +# error "missing INT32_WIDTH" +# endif +CHECK_WIDTH (int32_t, INT32_MAX, INT32_WIDTH); +#endif +#ifdef INT64_MAX +# ifndef INT64_WIDTH +# error "missing INT64_WIDTH" +# endif +CHECK_WIDTH (int64_t, INT64_MAX, INT64_WIDTH); +#endif +#ifdef UINT8_MAX +# ifndef UINT8_WIDTH +# error "missing UINT8_WIDTH" +# endif +CHECK_WIDTH (uint8_t, UINT8_MAX, UINT8_WIDTH); +#endif +#ifdef UINT16_MAX +# ifndef UINT16_WIDTH +# error "missing UINT16_WIDTH" +# endif +CHECK_WIDTH (uint16_t, UINT16_MAX, UINT16_WIDTH); +#endif +#ifdef UINT32_MAX +# ifndef UINT32_WIDTH +# error "missing UINT32_WIDTH" +# endif +CHECK_WIDTH (uint32_t, UINT32_MAX, UINT32_WIDTH); +#endif +#ifdef UINT64_MAX +# ifndef UINT64_WIDTH +# error "missing UINT64_WIDTH" +# endif +CHECK_WIDTH (uint64_t, UINT64_MAX, UINT64_WIDTH); +#endif + +#ifndef INT_LEAST8_WIDTH +# error "missing INT_LEAST8_WIDTH" +#endif +CHECK_WIDTH (int_least8_t, INT_LEAST8_MAX, INT_LEAST8_WIDTH); +#ifndef INT_LEAST16_WIDTH +# error "missing INT_LEAST16_WIDTH" +#endif +CHECK_WIDTH (int_least16_t, INT_LEAST16_MAX, INT_LEAST16_WIDTH); +#ifndef INT_LEAST32_WIDTH +# error "missing INT_LEAST32_WIDTH" +#endif +CHECK_WIDTH (int_least32_t, INT_LEAST32_MAX, INT_LEAST32_WIDTH); +#ifndef INT_LEAST64_WIDTH +# error "missing INT_LEAST64_WIDTH" +#endif +CHECK_WIDTH (int_least64_t, INT_LEAST64_MAX, INT_LEAST64_WIDTH); +#ifndef INT_LEAST8_WIDTH +# error "missing INT_LEAST8_WIDTH" +#endif +CHECK_WIDTH (uint_least8_t, UINT_LEAST8_MAX, UINT_LEAST8_WIDTH); +#ifndef UINT_LEAST16_WIDTH +# error "missing UINT_LEAST16_WIDTH" +#endif +CHECK_WIDTH (uint_least16_t, UINT_LEAST16_MAX, UINT_LEAST16_WIDTH); +#ifndef UINT_LEAST32_WIDTH +# error "missing UINT_LEAST32_WIDTH" +#endif +CHECK_WIDTH (uint_least32_t, UINT_LEAST32_MAX, UINT_LEAST32_WIDTH); +#ifndef UINT_LEAST64_WIDTH +# error "missing UINT_LEAST64_WIDTH" +#endif +CHECK_WIDTH (uint_least64_t, UINT_LEAST64_MAX, UINT_LEAST64_WIDTH); + +#ifndef INT_FAST8_WIDTH +# error "missing INT_FAST8_WIDTH" +#endif +CHECK_WIDTH (int_fast8_t, INT_FAST8_MAX, INT_FAST8_WIDTH); +#ifndef INT_FAST16_WIDTH +# error "missing INT_FAST16_WIDTH" +#endif +CHECK_WIDTH (int_fast16_t, INT_FAST16_MAX, INT_FAST16_WIDTH); +#ifndef INT_FAST32_WIDTH +# error "missing INT_FAST32_WIDTH" +#endif +CHECK_WIDTH (int_fast32_t, INT_FAST32_MAX, INT_FAST32_WIDTH); +#ifndef INT_FAST64_WIDTH +# error "missing INT_FAST64_WIDTH" +#endif +CHECK_WIDTH (int_fast64_t, INT_FAST64_MAX, INT_FAST64_WIDTH); +#ifndef INT_FAST8_WIDTH +# error "missing INT_FAST8_WIDTH" +#endif +CHECK_WIDTH (uint_fast8_t, UINT_FAST8_MAX, UINT_FAST8_WIDTH); +#ifndef UINT_FAST16_WIDTH +# error "missing UINT_FAST16_WIDTH" +#endif +CHECK_WIDTH (uint_fast16_t, UINT_FAST16_MAX, UINT_FAST16_WIDTH); +#ifndef UINT_FAST32_WIDTH +# error "missing UINT_FAST32_WIDTH" +#endif +CHECK_WIDTH (uint_fast32_t, UINT_FAST32_MAX, UINT_FAST32_WIDTH); +#ifndef UINT_FAST64_WIDTH +# error "missing UINT_FAST64_WIDTH" +#endif +CHECK_WIDTH (uint_fast64_t, UINT_FAST64_MAX, UINT_FAST64_WIDTH); + +#ifdef INTPTR_MAX +# ifndef INTPTR_WIDTH +# error "missing INTPTR_WIDTH" +# endif +CHECK_WIDTH (intptr_t, INTPTR_MAX, INTPTR_WIDTH); +#endif +#ifdef UINTPTR_MAX +# ifndef UINTPTR_WIDTH +# error "missing UINTPTR_WIDTH" +# endif +CHECK_WIDTH (uintptr_t, UINTPTR_MAX, UINTPTR_WIDTH); +#endif + +#ifndef INTMAX_WIDTH +# error "missing INTMAX_WIDTH" +#endif +CHECK_WIDTH (intmax_t, INTMAX_MAX, INTMAX_WIDTH); +#ifndef UINTMAX_WIDTH +# error "missing UINTMAX_WIDTH" +#endif +CHECK_WIDTH (uintmax_t, UINTMAX_MAX, UINTMAX_WIDTH); + +#ifndef PTRDIFF_WIDTH +# error "missing PTRDIFF_WIDTH" +#endif +CHECK_WIDTH (ptrdiff_t, PTRDIFF_MAX, PTRDIFF_WIDTH); +#ifndef SIGNAL_SUPPRESS +# ifndef SIG_ATOMIC_WIDTH +# error "missing SIG_ATOMIC_WIDTH" +# endif +CHECK_WIDTH (sig_atomic_t, SIG_ATOMIC_MAX, SIG_ATOMIC_WIDTH); +#endif +#ifndef SIZE_WIDTH +# error "missing SIZE_WIDTH" +#endif +CHECK_WIDTH (size_t, SIZE_MAX, SIZE_WIDTH); +#ifndef WCHAR_WIDTH +# error "missing WCHAR_WIDTH" +#endif +CHECK_WIDTH (wchar_t, WCHAR_MAX, WCHAR_WIDTH); +#ifndef WINT_WIDTH +# error "missing WINT_WIDTH" +#endif +CHECK_WIDTH (wint_t, WINT_MAX, WINT_WIDTH); diff --git a/gcc/testsuite/gcc.dg/torture/20131115-1.c b/gcc/testsuite/gcc.dg/torture/20131115-1.c index edb05f04c47..d0cdfa5a220 100644 --- a/gcc/testsuite/gcc.dg/torture/20131115-1.c +++ b/gcc/testsuite/gcc.dg/torture/20131115-1.c @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-skip-if "RAM usage too large" { "avr-*-*" } } */ struct S { int i; }; __attribute__((const, noinline, noclone)) diff --git a/gcc/testsuite/gcc.dg/torture/float128-builtin.c b/gcc/testsuite/gcc.dg/torture/float128-builtin.c index e4a50ceecff..ea3497ce9a8 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float128-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128-floath.c b/gcc/testsuite/gcc.dg/torture/float128-floath.c index 68147c35fb6..7b5b046e79f 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float128-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c b/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c index 5dfbff9e8ad..2f3b5c0d95e 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float128-tg-2.c b/gcc/testsuite/gcc.dg/torture/float128-tg-2.c index c7a32b176e8..eda98e58bbc 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float128-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128-tg.c b/gcc/testsuite/gcc.dg/torture/float128-tg.c index c1b6398d92b..d252ec545c1 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float128-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-builtin.c b/gcc/testsuite/gcc.dg/torture/float128x-builtin.c index 2e6bbaf28df..d75bc55a7dd 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-floath.c b/gcc/testsuite/gcc.dg/torture/float128x-floath.c index 0fc3db2744f..3ac96ce3177 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-nan.c b/gcc/testsuite/gcc.dg/torture/float128x-nan.c index ad0052fc434..c3eaf1218df 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c index e5c1b0c6989..31fa34eec7e 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-tg.c b/gcc/testsuite/gcc.dg/torture/float128x-tg.c index 0dc1e0f6823..751a3c64ffa 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float16-builtin.c b/gcc/testsuite/gcc.dg/torture/float16-builtin.c index 43f9b1936b5..4efe177c566 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float16-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float16-floath.c b/gcc/testsuite/gcc.dg/torture/float16-floath.c index 6857c2e9aa8..3748f4197df 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float16-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float16-nan.c b/gcc/testsuite/gcc.dg/torture/float16-nan.c index 859f30ca414..34cc50bdc20 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float16-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float16-tg-2.c b/gcc/testsuite/gcc.dg/torture/float16-tg-2.c index 4236018b0e7..ecb0fe448d1 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float16-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float16-tg.c b/gcc/testsuite/gcc.dg/torture/float16-tg.c index 39e8285b6e8..56c4e31394e 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float16-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float32-builtin.c b/gcc/testsuite/gcc.dg/torture/float32-builtin.c index fc14ad1e112..9b510266f82 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float32-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32-floath.c b/gcc/testsuite/gcc.dg/torture/float32-floath.c index 795cb21082f..dd503bef51f 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float32-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32-nan.c b/gcc/testsuite/gcc.dg/torture/float32-nan.c index c46b388a1c3..58ee6004a21 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float32-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float32-tg-2.c b/gcc/testsuite/gcc.dg/torture/float32-tg-2.c index 80441d720e2..c205ba2319e 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float32-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32-tg.c b/gcc/testsuite/gcc.dg/torture/float32-tg.c index da480ca87c5..b5ea060f8a2 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float32-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-builtin.c b/gcc/testsuite/gcc.dg/torture/float32x-builtin.c index 3a5c2d0aa67..71eb7e2cdc8 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-floath.c b/gcc/testsuite/gcc.dg/torture/float32x-floath.c index 49e7ba4ed3a..ef2005ca74c 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-nan.c b/gcc/testsuite/gcc.dg/torture/float32x-nan.c index 770499d0660..d976d379732 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c index 897130a280f..6179aba7cdd 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg.c b/gcc/testsuite/gcc.dg/torture/float32x-tg.c index 9f9a3bf8682..b65b03f558b 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float64-builtin.c b/gcc/testsuite/gcc.dg/torture/float64-builtin.c index ff3cb295676..413768443ae 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float64-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64-floath.c b/gcc/testsuite/gcc.dg/torture/float64-floath.c index a03d2e7dab7..3fb443b3726 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float64-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64-nan.c b/gcc/testsuite/gcc.dg/torture/float64-nan.c index 5f1a2e8f933..51a6437fd52 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float64-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c index dddaa82122a..d0e4316611f 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg.c b/gcc/testsuite/gcc.dg/torture/float64-tg.c index c970d53b5ec..a7188312d57 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float64-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-builtin.c b/gcc/testsuite/gcc.dg/torture/float64x-builtin.c index 2f95e8ad6d7..cc78ac011ad 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-floath.c b/gcc/testsuite/gcc.dg/torture/float64x-floath.c index 11eddc7036b..7fce730f386 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-nan.c b/gcc/testsuite/gcc.dg/torture/float64x-nan.c index 3d6496dee02..30e24b11e57 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c index 647d10406f0..8c3e4bdb802 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-tg.c b/gcc/testsuite/gcc.dg/torture/float64x-tg.c index ac14675a669..54a566c1e30 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/pr70421.c b/gcc/testsuite/gcc.dg/torture/pr70421.c index 8f97acd42be..1aa4d534599 100644 --- a/gcc/testsuite/gcc.dg/torture/pr70421.c +++ b/gcc/testsuite/gcc.dg/torture/pr70421.c @@ -1,5 +1,6 @@ /* PR target/70421 */ /* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ /* { dg-additional-options "-Wno-psabi -w" } */ typedef unsigned V __attribute__ ((vector_size (64))); diff --git a/gcc/testsuite/gcc.dg/torture/pr77436.c b/gcc/testsuite/gcc.dg/torture/pr77436.c new file mode 100644 index 00000000000..513867db7ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77436.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ + +int main() +{ + unsigned short sum = 0; + for (short x = -(__SHRT_MAX__ -1); x <= (__SHRT_MAX__ -1); x++) + sum += x; + if (sum != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr77479.c b/gcc/testsuite/gcc.dg/torture/pr77479.c new file mode 100644 index 00000000000..354ae5986ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77479.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fstrict-overflow -ftree-vrp" } */ + +void +vr (int of, unsigned char bw) +{ + int d1; + int lm = 0; + + for (d1 = 0; d1 < 3; ++d1) + { + const int vl = 2; + + while (bw < vl) + { + } + if (bw != vl) + lm -= vl; + } + while (++of < 1) + { + lm /= bw; + of += lm; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr77514.c b/gcc/testsuite/gcc.dg/torture/pr77514.c new file mode 100644 index 00000000000..464841ce364 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77514.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +void +m1 (char l0, char e8, int hw) +{ + char *rs = &l0; + +yu: + l0 = 1; + while (l0 != 0) + { + l0 = -l0; + l0 += (*rs ^ (l0 &= 1)); + } + for (;;) + { + if (hw != 0) + goto yu; + rs = &e8; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr77605.c b/gcc/testsuite/gcc.dg/torture/pr77605.c new file mode 100644 index 00000000000..3f1a26bc8d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77605.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +int a, b, c[2][8]; + +int main () +{ + for (a = 0; a < 8; a++) + for (b = 0; b < 2; b++) + c[b][a] = c[b][b + 6] ^ 1; + + if (c[0][7] != 0) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c index e9b04a0e67d..95d6ee3b4a3 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c @@ -1,4 +1,6 @@ /* { dg-options "-O0 -pthread -fprofile-update=atomic" } */ +/* { dg-require-effective-target profile_update_atomic } */ + #include <pthread.h> #define NUM_THREADS 8 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c b/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c index d678dc8c2cd..79e65aa01f4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-details" } */ +/* { dg-options "-O2 -fdump-tree-thread1-details -fdisable-tree-ethread" } */ extern void abort (void); @@ -40,4 +40,4 @@ c_finish_omp_clauses (tree clauses) /* There are 3 FSM jump threading opportunities, two of which will get filtered out. */ /* { dg-final { scan-tree-dump-times "Registering FSM" 1 "thread1"} } */ -/* { dg-final { scan-tree-dump-times "FSM Thread through multiway branch without threading a multiway branch" 2 "thread1"} } */ +/* { dg-final { scan-tree-dump-times "FSM Thread through multiway branch without threading a multiway branch" 2 "ethread"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c index 5842e28b94b..5f92447854b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c @@ -1,5 +1,5 @@ /* { dg-do compile { target sparc*-*-* x86_64-*-* } } */ -/* { dg-options "-O2 -fdump-tree-thread1-details" } */ +/* { dg-options "-O2 -fdump-tree-thread1-details -fdisable-tree-ethread" } */ /* { dg-final { scan-tree-dump "FSM did not thread around loop and would copy too many statements" "thread1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c index eb66136e47f..e1c33e86cd7 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-dom2-stats" } */ +/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-dom2-stats -fdisable-tree-ethread" } */ void foo(); void bla(); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c index f5f338ba357..061f2235533 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-details" } */ -/* { dg-final { scan-tree-dump "FSM" "thread1" } } */ +/* { dg-options "-O2 -fdump-tree-ethread-details" } */ +/* { dg-final { scan-tree-dump "FSM" "ethread" } } */ typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c index c6d10c2dbcf..f25f2761d47 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdisable-tree-ethread" } */ int foo (int *p, int i) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c index 3a64b017c18..c2870c45907 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-stats" } */ +/* { dg-options "-O2 -fdump-tree-ethread-stats" } */ typedef struct basic_block_def *basic_block; struct basic_block_def; struct edge_def; @@ -38,5 +38,5 @@ cleanup_empty_eh (basic_block bb) foo (); } } -/* { dg-final { scan-tree-dump "Jumps threaded: 1" "thread1"} } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 1" "ethread"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c index b096e9b3602..5d5375073e6 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details -fdisable-tree-ethread" } */ void bar (void); int foo (int i, int j) diff --git a/gcc/testsuite/gcc.dg/uninit-15.c b/gcc/testsuite/gcc.dg/uninit-15.c index 20bea95acd8..6154f4b638a 100644 --- a/gcc/testsuite/gcc.dg/uninit-15.c +++ b/gcc/testsuite/gcc.dg/uninit-15.c @@ -1,16 +1,16 @@ /* PR tree-optimization/17506 We issue an uninitialized variable warning at a wrong location at line 11, which is very confusing. Make sure we print out a note to - make it less confusing. (xfailed alternative) + make it less confusing. (not xfailed alternative) But it is of course ok if we warn in bar about uninitialized use - of j. (not xfailed alternative) */ + of j. (xfailed alternative) */ /* { dg-do compile } */ /* { dg-options "-O1 -Wuninitialized" } */ inline int foo (int i) { - if (i) /* { dg-warning "used uninitialized in this function" "" { xfail *-*-* } } */ + if (i) /* { dg-warning "used uninitialized in this function" } */ return 1; return 0; } @@ -20,7 +20,7 @@ void baz (void); void bar (void) { - int j; /* { dg-message "note: 'j' was declared here" "" { xfail *-*-* } } */ - for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" } */ + int j; /* { dg-message "note: 'j' was declared here" } */ + for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" "" { xfail *-*-* } } */ baz (); } diff --git a/gcc/testsuite/gcc.dg/vect/pr77503.c b/gcc/testsuite/gcc.dg/vect/pr77503.c new file mode 100644 index 00000000000..609e7fb5fd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr77503.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ +/* { dg-skip-if "need vect_max_reduc support" { ! vect_max_reduc } } */ + +extern void d(void); +void a() { + char *b; + char c = 0; + for (; b < (char *)a; b++) { + if (*b) + c = 1; + *b = 0; + } + if (c) + d(); +} +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ |